├── LICENSE ├── src └── CreateServiceBusOrEventHubsSASToken.js ├── collections ├── AzureEventGridAPI.postman_collection.json ├── AzureEventHubsAPI.postman_collection.json ├── AzureStorageAPI.postman_collection.json └── AzureServiceBusMessagingAPI.postman_collection.json ├── README.md └── .gitignore /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Ludvig Falck 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/CreateServiceBusOrEventHubsSASToken.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Create a Shared Access Signature (SAS) token valid for one minute for use with the Azure Service Bus or Event Hubs REST APIs 3 | * Based on https://docs.microsoft.com/en-us/rest/api/eventhub/generate-sas-token but modified to use crypto-js for compatibility with Postman 4 | * @param resourceUri - The full uri of the resource, e.g. https://.servicebus.windows.net 5 | * @param sasKeyName - The name of the Shared Access Signature key 6 | * @param sasKey - The Shared Access Signature key 7 | * @returns- A Shared Access Signature token 8 | * {@link https://github.com/lfalck/AzureRestApiPostmanCollections GitHub} 9 | * 10 | */ 11 | function createServiceBusOrEventHubsSASToken(resourceUri, sasKeyName, sasKey) { 12 | if (!resourceUri || !sasKeyName || !sasKey) { 13 | throw "Missing required parameter"; 14 | } 15 | const encoded = encodeURIComponent(resourceUri); 16 | const now = new Date(); 17 | const minute = 60; 18 | const ttl = Math.round(now.getTime() / 1000) + minute; 19 | const signature = encoded + '\n' + ttl; 20 | const hash = CryptoJS.HmacSHA256(signature, sasKey).toString(CryptoJS.enc.Base64); 21 | return 'SharedAccessSignature sr=' + encoded + '&sig=' + 22 | encodeURIComponent(hash) + '&se=' + ttl + '&skn=' + sasKeyName; 23 | } -------------------------------------------------------------------------------- /collections/AzureEventGridAPI.postman_collection.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "_postman_id": "a6a3d80d-a13f-45fb-90e2-3eef574f4bff", 4 | "name": "Azure Event Grid API", 5 | "description": "Publish to Azure Event Grid \n[Documentation](https://docs.microsoft.com/en-us/azure/event-grid/)", 6 | "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" 7 | }, 8 | "item": [ 9 | { 10 | "name": "Send Event", 11 | "request": { 12 | "method": "POST", 13 | "header": [ 14 | { 15 | "key": "aeg-sas-key", 16 | "value": "{{sasKey}}", 17 | "description": "Event Grid SAS key from portal." 18 | }, 19 | { 20 | "key": "Content-Type", 21 | "value": "application/json" 22 | } 23 | ], 24 | "body": { 25 | "mode": "raw", 26 | "raw": "[{\r\n \"id\": \"{{$guid}}\",\r\n \"eventType\": \"recordInserted\",\r\n \"subject\": \"myapp/messages\",\r\n \"eventTime\": \"{{currentTime}}\",\r\n \"data\": {\r\n \"message\": \"Hello World Event Grid!\"\r\n },\r\n \"dataVersion\": \"1.0\"\r\n}]" 27 | }, 28 | "url": { 29 | "raw": "{{topic-endpoint}}?api-version={{api-version}}", 30 | "host": [ 31 | "{{topic-endpoint}}" 32 | ], 33 | "query": [ 34 | { 35 | "key": "api-version", 36 | "value": "{{api-version}}" 37 | } 38 | ] 39 | }, 40 | "description": "Post to custom topic for Azure Event Grid.\n[Documentation](https://docs.microsoft.com/en-us/azure/event-grid/post-to-custom-topic)" 41 | }, 42 | "response": [] 43 | } 44 | ], 45 | "event": [ 46 | { 47 | "listen": "prerequest", 48 | "script": { 49 | "id": "4f21bd54-03b9-463b-b317-09934dc6b741", 50 | "type": "text/javascript", 51 | "exec": [ 52 | "const currentTime = new Date().toISOString();", 53 | "pm.variables.set(\"currentTime\", currentTime);" 54 | ] 55 | } 56 | }, 57 | { 58 | "listen": "test", 59 | "script": { 60 | "id": "01eb605c-7f4d-45fa-9eb0-ed3047acfdf6", 61 | "type": "text/javascript", 62 | "exec": [ 63 | "" 64 | ] 65 | } 66 | } 67 | ], 68 | "variable": [ 69 | { 70 | "id": "808c3311-a69c-40ce-87bf-beb88c000faf", 71 | "key": "topic-endpoint", 72 | "value": "https://<>.eventgrid.azure.net/api/events", 73 | "type": "string", 74 | "description": "" 75 | }, 76 | { 77 | "id": "bf8805ea-e07b-40ea-ba3a-d1fe7b7c0d51", 78 | "key": "api-version", 79 | "value": "2018-01-01", 80 | "type": "string", 81 | "description": "" 82 | }, 83 | { 84 | "id": "6d4cfdcf-d3f2-4469-918f-08f1d79a2cae", 85 | "key": "eventTime", 86 | "value": "Automatically generated in collection pre request script", 87 | "type": "string", 88 | "description": "" 89 | }, 90 | { 91 | "id": "518a6c90-8da8-4ede-b006-e73df9d8243e", 92 | "key": "sasKey", 93 | "value": "Enter here or in an environment variable", 94 | "type": "string", 95 | "description": "" 96 | } 97 | ] 98 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![license](https://img.shields.io/github/license/lfalck/AzureRestApiPostmanCollections.svg)]() 2 | # Azure REST API Postman Collections 3 | Postman collections to simplify interaction with the Azure REST APIs, focusing on those relevant for systems integration developers. 4 | 5 | If you need multiple environments you can create environment variables with the same names as the collection variables and they will be overridden. If you need multiple e.g. queues, you can copy a request and change the path variables. 6 | 7 | Collection variables are found by right clicking and selecting edit on a collection. Path variables are found by clicking "Params" when a request is open. 8 | 9 | API documentation by Microsoft copied from https://docs.microsoft.com is licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). 10 | 11 | ## Azure Service Bus Messaging API 12 | 13 | Send and receive messages using the [Service Bus Messaging API](https://docs.microsoft.com/en-us/rest/api/servicebus/service-bus-runtime-rest) 14 | 15 | | Variable | Type | Description | 16 | | -------------------------- | ------------------------ | --------------------------------------------------------------------------------- | 17 | | servicebusNamespace | Collection variable | The service bus namespace name | 18 | | sasKeyName | Collection variable | Policy name from Service Bus Namespace > Shared access policies | 19 | | sasKey | Collection variable | Key from Service Bus Namespace > Shared access policies | 20 | | queueName | Path variable | Queue name from Service Bus Namespace > Queues | 21 | | topicName | Path variable | Topic name from Service Bus Namespace > Topics | 22 | | subscriptionName | Path variable | Subscription name from Service Bus Namespace > Topics > Subscriptions | 23 | 24 | 25 | ## Azure Event Hubs API 26 | 27 | Send events using the [Event Hubs API](https://docs.microsoft.com/en-us/rest/api/eventhub/event-hubs-runtime-rest) 28 | 29 | | Variable | Type | Description | 30 | | -------------------------- | ------------------------ | --------------------------------------------------------------------------------- | 31 | | servicebusNamespace | Collection variable | The event hubs namespace name | 32 | | sasKeyName | Collection variable | Policy name from Event Hubs Namespace > Shared access policies | 33 | | sasKey | Collection variable | Key from Event Hubs Namespace > Shared access policies | 34 | | eventHubPath | Path variable | Event hub name from Event Hubs Namespace > Event Hubs | 35 | | partitionId | Path variable | Optional partition id | 36 | 37 | ## Azure Storage API 38 | 39 | Send and receive messages using the [Queue Service API](https://docs.microsoft.com/en-us/rest/api/storageservices/operations-on-messages) 40 | Work with the [Blob Service API](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api) 41 | 42 | | Variable | Type | Description | 43 | | -------------------------- | ------------------------ | --------------------------------------------------------------------------------- | 44 | | storageAccountName | Collection variable | The event hubs namespace name | 45 | | storageSasTokenQueryString | Collection variable | Query string from Storage accounts > Shared access signature with "?sv=" removed. | 46 | | storageQueueName | Path variable | Queue name from Storage accounts > Queues | 47 | | storageContainerName | Path variable | Container name from Storage accounts > Containers | 48 | | storageBlobName | Path variable | Blob name from Storage accounts > Containers | 49 | 50 | 51 | ## Azure Event Grid API 52 | Send events to custom Azure Event Grid Topics 53 | 54 | | Variable | Type | Description | 55 | | -------------------------- | ------------------------ | --------------------------------------------------------------------------------- | 56 | | sasKey | Collection variable | Key from Event Grid Topics > Access keys | 57 | | topic-endpoint | Collection variable | Topic endpoint from Event Grid Topics > Overview > Topic Endpoint | 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # .NET Core 46 | project.lock.json 47 | project.fragment.lock.json 48 | artifacts/ 49 | **/Properties/launchSettings.json 50 | 51 | *_i.c 52 | *_p.c 53 | *_i.h 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.tmp_proj 68 | *.log 69 | *.vspscc 70 | *.vssscc 71 | .builds 72 | *.pidb 73 | *.svclog 74 | *.scc 75 | 76 | # Chutzpah Test files 77 | _Chutzpah* 78 | 79 | # Visual C++ cache files 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opendb 84 | *.opensdf 85 | *.sdf 86 | *.cachefile 87 | *.VC.db 88 | *.VC.VC.opendb 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | *.sap 95 | 96 | # TFS 2012 Local Workspace 97 | $tf/ 98 | 99 | # Guidance Automation Toolkit 100 | *.gpState 101 | 102 | # ReSharper is a .NET coding add-in 103 | _ReSharper*/ 104 | *.[Rr]e[Ss]harper 105 | *.DotSettings.user 106 | 107 | # JustCode is a .NET coding add-in 108 | .JustCode 109 | 110 | # TeamCity is a build add-in 111 | _TeamCity* 112 | 113 | # DotCover is a Code Coverage Tool 114 | *.dotCover 115 | 116 | # Visual Studio code coverage results 117 | *.coverage 118 | *.coveragexml 119 | 120 | # NCrunch 121 | _NCrunch_* 122 | .*crunch*.local.xml 123 | nCrunchTemp_* 124 | 125 | # MightyMoose 126 | *.mm.* 127 | AutoTest.Net/ 128 | 129 | # Web workbench (sass) 130 | .sass-cache/ 131 | 132 | # Installshield output folder 133 | [Ee]xpress/ 134 | 135 | # DocProject is a documentation generator add-in 136 | DocProject/buildhelp/ 137 | DocProject/Help/*.HxT 138 | DocProject/Help/*.HxC 139 | DocProject/Help/*.hhc 140 | DocProject/Help/*.hhk 141 | DocProject/Help/*.hhp 142 | DocProject/Help/Html2 143 | DocProject/Help/html 144 | 145 | # Click-Once directory 146 | publish/ 147 | 148 | # Publish Web Output 149 | *.[Pp]ublish.xml 150 | *.azurePubxml 151 | # TODO: Comment the next line if you want to checkin your web deploy settings 152 | # but database connection strings (with potential passwords) will be unencrypted 153 | *.pubxml 154 | *.publishproj 155 | 156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 157 | # checkin your Azure Web App publish settings, but sensitive information contained 158 | # in these scripts will be unencrypted 159 | PublishScripts/ 160 | 161 | # NuGet Packages 162 | *.nupkg 163 | # The packages folder can be ignored because of Package Restore 164 | **/packages/* 165 | # except build/, which is used as an MSBuild target. 166 | !**/packages/build/ 167 | # Uncomment if necessary however generally it will be regenerated when needed 168 | #!**/packages/repositories.config 169 | # NuGet v3's project.json files produces more ignorable files 170 | *.nuget.props 171 | *.nuget.targets 172 | 173 | # Microsoft Azure Build Output 174 | csx/ 175 | *.build.csdef 176 | 177 | # Microsoft Azure Emulator 178 | ecf/ 179 | rcf/ 180 | 181 | # Windows Store app package directories and files 182 | AppPackages/ 183 | BundleArtifacts/ 184 | Package.StoreAssociation.xml 185 | _pkginfo.txt 186 | 187 | # Visual Studio cache files 188 | # files ending in .cache can be ignored 189 | *.[Cc]ache 190 | # but keep track of directories ending in .cache 191 | !*.[Cc]ache/ 192 | 193 | # Others 194 | ClientBin/ 195 | ~$* 196 | *~ 197 | *.dbmdl 198 | *.dbproj.schemaview 199 | *.jfm 200 | *.pfx 201 | *.publishsettings 202 | orleans.codegen.cs 203 | 204 | # Since there are multiple workflows, uncomment next line to ignore bower_components 205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 206 | #bower_components/ 207 | 208 | # RIA/Silverlight projects 209 | Generated_Code/ 210 | 211 | # Backup & report files from converting an old project file 212 | # to a newer Visual Studio version. Backup files are not needed, 213 | # because we have git ;-) 214 | _UpgradeReport_Files/ 215 | Backup*/ 216 | UpgradeLog*.XML 217 | UpgradeLog*.htm 218 | 219 | # SQL Server files 220 | *.mdf 221 | *.ldf 222 | *.ndf 223 | 224 | # Business Intelligence projects 225 | *.rdl.data 226 | *.bim.layout 227 | *.bim_*.settings 228 | 229 | # Microsoft Fakes 230 | FakesAssemblies/ 231 | 232 | # GhostDoc plugin setting file 233 | *.GhostDoc.xml 234 | 235 | # Node.js Tools for Visual Studio 236 | .ntvs_analysis.dat 237 | node_modules/ 238 | 239 | # Typescript v1 declaration files 240 | typings/ 241 | 242 | # Visual Studio 6 build log 243 | *.plg 244 | 245 | # Visual Studio 6 workspace options file 246 | *.opt 247 | 248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 249 | *.vbw 250 | 251 | # Visual Studio LightSwitch build output 252 | **/*.HTMLClient/GeneratedArtifacts 253 | **/*.DesktopClient/GeneratedArtifacts 254 | **/*.DesktopClient/ModelManifest.xml 255 | **/*.Server/GeneratedArtifacts 256 | **/*.Server/ModelManifest.xml 257 | _Pvt_Extensions 258 | 259 | # Paket dependency manager 260 | .paket/paket.exe 261 | paket-files/ 262 | 263 | # FAKE - F# Make 264 | .fake/ 265 | 266 | # JetBrains Rider 267 | .idea/ 268 | *.sln.iml 269 | 270 | # CodeRush 271 | .cr/ 272 | 273 | # Python Tools for Visual Studio (PTVS) 274 | __pycache__/ 275 | *.pyc 276 | 277 | # Cake - Uncomment if you are using it 278 | # tools/** 279 | # !tools/packages.config 280 | 281 | # Telerik's JustMock configuration file 282 | *.jmconfig 283 | 284 | # BizTalk build output 285 | *.btp.cs 286 | *.btm.cs 287 | *.odx.cs 288 | *.xsd.cs 289 | -------------------------------------------------------------------------------- /collections/AzureEventHubsAPI.postman_collection.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "_postman_id": "6b9ab7c4-47c3-49c2-bcfc-8ba32e1a5a6e", 4 | "name": "Azure Event Hubs API", 5 | "description": "Send events using the Event Hubs API. \n[Documentation](https://docs.microsoft.com/en-us/rest/api/eventhub/event-hubs-runtime-rest)", 6 | "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" 7 | }, 8 | "item": [ 9 | { 10 | "name": "Event Hub", 11 | "description": null, 12 | "item": [ 13 | { 14 | "name": "Send batch events", 15 | "event": [ 16 | { 17 | "listen": "prerequest", 18 | "script": { 19 | "id": "ddbe4407-0a04-4d8e-ab3a-486358c6514e", 20 | "type": "text/javascript", 21 | "exec": [ 22 | "" 23 | ] 24 | } 25 | } 26 | ], 27 | "request": { 28 | "method": "POST", 29 | "header": [ 30 | { 31 | "key": "Authorization", 32 | "value": "{{sasToken}}", 33 | "description": "SAS token generated in pre-request script in collection" 34 | }, 35 | { 36 | "key": "Content-Type", 37 | "value": "application/vnd.microsoft.servicebus.json", 38 | "description": "Set to application/vnd.microsoft.servicebus.json for batch events" 39 | } 40 | ], 41 | "body": { 42 | "mode": "raw", 43 | "raw": "[\r\n\t{\"Body\":\"Message1\"},\r\n\t{\"Body\":\"Message2\"},\r\n\t{\"Body\":\"Message3\"}\r\n] \r\n" 44 | }, 45 | "url": { 46 | "raw": "https://{{servicebusNamespace}}.servicebus.windows.net/:eventHubPath/messages", 47 | "protocol": "https", 48 | "host": [ 49 | "{{servicebusNamespace}}", 50 | "servicebus", 51 | "windows", 52 | "net" 53 | ], 54 | "path": [ 55 | ":eventHubPath", 56 | "messages" 57 | ], 58 | "variable": [ 59 | { 60 | "key": "eventHubPath", 61 | "value": "" 62 | } 63 | ] 64 | }, 65 | "description": "Sends a new batched message event to an Event Hub.\r\n\r\n[Documentation](https://docs.microsoft.com/en-us/rest/api/eventhub/send-batch-events)" 66 | }, 67 | "response": [] 68 | }, 69 | { 70 | "name": "Send Event", 71 | "event": [ 72 | { 73 | "listen": "prerequest", 74 | "script": { 75 | "id": "ddbe4407-0a04-4d8e-ab3a-486358c6514e", 76 | "type": "text/javascript", 77 | "exec": [ 78 | "" 79 | ] 80 | } 81 | } 82 | ], 83 | "request": { 84 | "method": "POST", 85 | "header": [ 86 | { 87 | "key": "Authorization", 88 | "value": "{{sasToken}}", 89 | "description": "SAS token generated in pre-request script in collection" 90 | }, 91 | { 92 | "key": "Content-Type", 93 | "value": "application/atom+xml;type=entry;charset=utf-8" 94 | } 95 | ], 96 | "body": { 97 | "mode": "raw", 98 | "raw": "Hello World!" 99 | }, 100 | "url": { 101 | "raw": "https://{{servicebusNamespace}}.servicebus.windows.net/:eventHubPath/messages?api-version={{api-version}}", 102 | "protocol": "https", 103 | "host": [ 104 | "{{servicebusNamespace}}", 105 | "servicebus", 106 | "windows", 107 | "net" 108 | ], 109 | "path": [ 110 | ":eventHubPath", 111 | "messages" 112 | ], 113 | "query": [ 114 | { 115 | "key": "api-version", 116 | "value": "{{api-version}}" 117 | } 118 | ], 119 | "variable": [ 120 | { 121 | "key": "eventHubPath", 122 | "value": "" 123 | } 124 | ] 125 | }, 126 | "description": "Sends a new event to an Event Hub. \n[Documentation](https://docs.microsoft.com/en-us/rest/api/eventhub/send-event)" 127 | }, 128 | "response": [] 129 | }, 130 | { 131 | "name": "Send partition event", 132 | "event": [ 133 | { 134 | "listen": "prerequest", 135 | "script": { 136 | "id": "ddbe4407-0a04-4d8e-ab3a-486358c6514e", 137 | "type": "text/javascript", 138 | "exec": [ 139 | "" 140 | ] 141 | } 142 | } 143 | ], 144 | "request": { 145 | "method": "POST", 146 | "header": [ 147 | { 148 | "key": "Authorization", 149 | "value": "{{sasToken}}", 150 | "description": "SAS token generated in pre-request script in collection" 151 | }, 152 | { 153 | "key": "Content-Type", 154 | "value": "application/atom+xml;type=entry;charset=utf-8" 155 | } 156 | ], 157 | "body": { 158 | "mode": "raw", 159 | "raw": "Hello World!" 160 | }, 161 | "url": { 162 | "raw": "https://{{servicebusNamespace}}.servicebus.windows.net/:eventHubPath/partitions/:partitionId/messages", 163 | "protocol": "https", 164 | "host": [ 165 | "{{servicebusNamespace}}", 166 | "servicebus", 167 | "windows", 168 | "net" 169 | ], 170 | "path": [ 171 | ":eventHubPath", 172 | "partitions", 173 | ":partitionId", 174 | "messages" 175 | ], 176 | "variable": [ 177 | { 178 | "key": "eventHubPath", 179 | "value": "" 180 | }, 181 | { 182 | "key": "partitionId", 183 | "value": "" 184 | } 185 | ] 186 | }, 187 | "description": "Sends a new event to a specified partition in an Event Hub.\r\n\r\n[Documentation](https://docs.microsoft.com/en-us/rest/api/eventhub/send-partition-event)" 188 | }, 189 | "response": [] 190 | } 191 | ], 192 | "event": [ 193 | { 194 | "listen": "prerequest", 195 | "script": { 196 | "id": "ad24c7bb-e8a1-444d-8556-c298943460aa", 197 | "type": "text/javascript", 198 | "exec": [ 199 | "" 200 | ] 201 | } 202 | }, 203 | { 204 | "listen": "test", 205 | "script": { 206 | "id": "1b5dd321-fac8-472e-bd95-09150963254f", 207 | "type": "text/javascript", 208 | "exec": [ 209 | "" 210 | ] 211 | } 212 | } 213 | ] 214 | } 215 | ], 216 | "event": [ 217 | { 218 | "listen": "prerequest", 219 | "script": { 220 | "id": "cd54c413-85bc-46e8-9a93-b3f6abe9a93a", 221 | "type": "text/javascript", 222 | "exec": [ 223 | "const servicebusNamespace = pm.variables.get(\"servicebusNamespace\");", 224 | "const namespaceUri = \"https://\"+servicebusNamespace+\".servicebus.windows.net\";", 225 | "const sasKeyName = pm.variables.get(\"sasKeyName\");", 226 | "const sasKey = pm.variables.get(\"sasKey\");", 227 | "const sasToken = createServiceBusOrEventHubsSASToken(namespaceUri, sasKeyName, sasKey);", 228 | "", 229 | "pm.variables.set(\"sasToken\", sasToken);", 230 | "", 231 | "/**", 232 | " * Create a Shared Access Signature (SAS) token valid for one minute for use with the Azure Service Bus or Event Hubs REST APIs", 233 | " * Based on https://docs.microsoft.com/en-us/rest/api/eventhub/generate-sas-token but modified to use crypto-js for compatibility with Postman", 234 | " * @param resourceUri - The full uri of the resource, e.g. https://.servicebus.windows.net", 235 | " * @param sasKeyName - The name of the Shared Access Signature key", 236 | " * @param sasKey - The Shared Access Signature key", 237 | " * @returns- A Shared Access Signature token", 238 | " * {@link https://github.com/lfalck/AzureRestApiPostmanCollections GitHub}", 239 | " * ", 240 | " */", 241 | "function createServiceBusOrEventHubsSASToken(resourceUri, sasKeyName, sasKey) {", 242 | " if (!resourceUri || !sasKeyName || !sasKey) {", 243 | " throw \"Missing required parameter\";", 244 | " }", 245 | " const encoded = encodeURIComponent(resourceUri);", 246 | " const now = new Date();", 247 | " const minute = 60;", 248 | " const ttl = Math.round(now.getTime() / 1000) + minute;", 249 | " const signature = encoded + '\\n' + ttl;", 250 | " const hash = CryptoJS.HmacSHA256(signature, sasKey).toString(CryptoJS.enc.Base64);", 251 | " return 'SharedAccessSignature sr=' + encoded + '&sig=' +", 252 | " encodeURIComponent(hash) + '&se=' + ttl + '&skn=' + sasKeyName;", 253 | "}" 254 | ] 255 | } 256 | }, 257 | { 258 | "listen": "test", 259 | "script": { 260 | "id": "927b8013-707c-4f34-bc73-054bbaa667b7", 261 | "type": "text/javascript", 262 | "exec": [ 263 | "" 264 | ] 265 | } 266 | } 267 | ], 268 | "variable": [ 269 | { 270 | "id": "931609c4-1908-45da-87e0-91b7262abcc9", 271 | "key": "servicebusNamespace", 272 | "value": "Event Hubs Namespace Name", 273 | "type": "string" 274 | }, 275 | { 276 | "id": "8d5c8d0e-de61-4a8e-b29b-f83b967877aa", 277 | "key": "sasKeyName", 278 | "value": "Enter here or in an environment variable", 279 | "type": "string" 280 | }, 281 | { 282 | "id": "95020630-4a59-4788-b473-023d577e8b28", 283 | "key": "sasKey", 284 | "value": "Enter here or in an environment variable", 285 | "type": "string" 286 | }, 287 | { 288 | "id": "3c3355a2-40b8-415f-93b8-c6808d956f6a", 289 | "key": "sasToken", 290 | "value": "Automatically generated in collection pre request script", 291 | "type": "string" 292 | }, 293 | { 294 | "id": "7fb039f6-7ac6-486c-a327-a3c072350863", 295 | "key": "api-version", 296 | "value": "2014-01", 297 | "type": "string" 298 | } 299 | ] 300 | } -------------------------------------------------------------------------------- /collections/AzureStorageAPI.postman_collection.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "_postman_id": "5b1a63a0-642d-4a8b-9e0f-df185b1cb443", 4 | "name": "Azure Storage API", 5 | "description": "The REST APIs for the Microsoft Azure storage services offer programmatic access to the Blob, Queue, Table, and File services in Azure or in the development environment, via the storage emulator. \n[Documentation](https://docs.microsoft.com/en-us/rest/api/storageservices/azure-storage-services-rest-api-reference)", 6 | "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" 7 | }, 8 | "item": [ 9 | { 10 | "name": "Queue", 11 | "description": "Microsoft Azure Storage provides REST operations for working with messages in message queues.\n\n[Documentation](https://docs.microsoft.com/en-us/rest/api/storageservices/operations-on-messages)", 12 | "item": [ 13 | { 14 | "name": "Get Messages", 15 | "request": { 16 | "method": "GET", 17 | "header": [], 18 | "body": {}, 19 | "url": { 20 | "raw": "https://{{storageAccountName}}.queue.core.windows.net/:storageQueueName/messages{{storageSasTokenQueryString}}&numofmessages=1", 21 | "protocol": "https", 22 | "host": [ 23 | "{{storageAccountName}}", 24 | "queue", 25 | "core", 26 | "windows", 27 | "net" 28 | ], 29 | "path": [ 30 | ":storageQueueName", 31 | "messages{{storageSasTokenQueryString}}&numofmessages=1" 32 | ], 33 | "variable": [ 34 | { 35 | "key": "storageQueueName", 36 | "value": "" 37 | } 38 | ] 39 | }, 40 | "description": "The Get Messages operation retrieves one or more messages from the front of the queue. \n\n[Documentation](https://docs.microsoft.com/en-us/rest/api/storageservices/get-messages)" 41 | }, 42 | "response": [] 43 | }, 44 | { 45 | "name": "Peek Messages", 46 | "request": { 47 | "method": "GET", 48 | "header": [], 49 | "body": {}, 50 | "url": { 51 | "raw": "https://{{storageAccountName}}.queue.core.windows.net/:storageQueueName/messages{{storageSasTokenQueryString}}&numofmessages=1&peekonly=true", 52 | "protocol": "https", 53 | "host": [ 54 | "{{storageAccountName}}", 55 | "queue", 56 | "core", 57 | "windows", 58 | "net" 59 | ], 60 | "path": [ 61 | ":storageQueueName", 62 | "messages{{storageSasTokenQueryString}}&numofmessages=1&peekonly=true" 63 | ], 64 | "variable": [ 65 | { 66 | "key": "storageQueueName", 67 | "value": "" 68 | } 69 | ] 70 | }, 71 | "description": "This operation retrieves one or more messages from the front of the queue, but does not alter the visibility of the message. \r\n\r\n[Documentation](https://docs.microsoft.com/en-us/rest/api/storageservices/peek-messages)" 72 | }, 73 | "response": [] 74 | }, 75 | { 76 | "name": "Put Message", 77 | "request": { 78 | "method": "POST", 79 | "header": [ 80 | { 81 | "key": "Content-Type", 82 | "value": "application/xml" 83 | } 84 | ], 85 | "body": { 86 | "mode": "raw", 87 | "raw": " \r\n \r\n Hello World!\r\n \r\n " 88 | }, 89 | "url": { 90 | "raw": "https://{{storageAccountName}}.queue.core.windows.net/:storageQueueName/messages{{storageSasTokenQueryString}}", 91 | "protocol": "https", 92 | "host": [ 93 | "{{storageAccountName}}", 94 | "queue", 95 | "core", 96 | "windows", 97 | "net" 98 | ], 99 | "path": [ 100 | ":storageQueueName", 101 | "messages{{storageSasTokenQueryString}}" 102 | ], 103 | "variable": [ 104 | { 105 | "key": "storageQueueName", 106 | "value": "" 107 | } 108 | ] 109 | }, 110 | "description": "The Put Message operation adds a new message to the back of the message queue. \n\n[Documentation](https://docs.microsoft.com/en-us/rest/api/storageservices/put-message)" 111 | }, 112 | "response": [] 113 | }, 114 | { 115 | "name": "Delete Message", 116 | "request": { 117 | "method": "DELETE", 118 | "header": [], 119 | "body": {}, 120 | "url": { 121 | "raw": "https://{{storageAccountName}}.queue.core.windows.net/:storageQueueName/messages{{storageSasTokenQueryString}}&popreceipt=", 122 | "protocol": "https", 123 | "host": [ 124 | "{{storageAccountName}}", 125 | "queue", 126 | "core", 127 | "windows", 128 | "net" 129 | ], 130 | "path": [ 131 | ":storageQueueName", 132 | "messages{{storageSasTokenQueryString}}&popreceipt=" 133 | ], 134 | "variable": [ 135 | { 136 | "key": "storageQueueName", 137 | "value": "" 138 | } 139 | ] 140 | }, 141 | "description": "The Delete Message operation deletes the specified message. \n\n[Documentation](https://docs.microsoft.com/en-us/rest/api/storageservices/delete-message2)" 142 | }, 143 | "response": [] 144 | }, 145 | { 146 | "name": "Clear Messages", 147 | "request": { 148 | "method": "DELETE", 149 | "header": [], 150 | "body": {}, 151 | "url": { 152 | "raw": "https://{{storageAccountName}}.queue.core.windows.net/:storageQueueName/messages{{storageSasTokenQueryString}}", 153 | "protocol": "https", 154 | "host": [ 155 | "{{storageAccountName}}", 156 | "queue", 157 | "core", 158 | "windows", 159 | "net" 160 | ], 161 | "path": [ 162 | ":storageQueueName", 163 | "messages{{storageSasTokenQueryString}}" 164 | ], 165 | "variable": [ 166 | { 167 | "key": "storageQueueName", 168 | "value": "" 169 | } 170 | ] 171 | }, 172 | "description": "The Clear Messages operation deletes all messages from the specified queue. \n\n[Documentation](https://docs.microsoft.com/en-us/rest/api/storageservices/clear-messages)" 173 | }, 174 | "response": [] 175 | } 176 | ], 177 | "event": [ 178 | { 179 | "listen": "prerequest", 180 | "script": { 181 | "id": "8c0605db-bcd4-49ba-b642-6936e3a74c89", 182 | "type": "text/javascript", 183 | "exec": [ 184 | "" 185 | ] 186 | } 187 | }, 188 | { 189 | "listen": "test", 190 | "script": { 191 | "id": "6647b32f-1730-499e-978c-fc73b6851697", 192 | "type": "text/javascript", 193 | "exec": [ 194 | "" 195 | ] 196 | } 197 | } 198 | ] 199 | }, 200 | { 201 | "name": "Blob", 202 | "description": "The REST API for the Blob service defines HTTP operations against container and blob resources. \n\n[Documentation](https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api)", 203 | "item": [ 204 | { 205 | "name": "Get Blob", 206 | "request": { 207 | "method": "GET", 208 | "header": [], 209 | "body": {}, 210 | "url": { 211 | "raw": "https://{{storageAccountName}}.blob.core.windows.net/:storageContainerName/:storageBlobName?sv={{storageSasTokenQueryString}}", 212 | "protocol": "https", 213 | "host": [ 214 | "{{storageAccountName}}", 215 | "blob", 216 | "core", 217 | "windows", 218 | "net" 219 | ], 220 | "path": [ 221 | ":storageContainerName", 222 | ":storageBlobName" 223 | ], 224 | "query": [ 225 | { 226 | "key": "sv", 227 | "value": "{{storageSasTokenQueryString}}", 228 | "description": "SAS token query string from Storage accounts > Shared access signature. Remove the part \"?sv=\" since this is part of the URI." 229 | } 230 | ], 231 | "variable": [ 232 | { 233 | "key": "storageContainerName", 234 | "value": "" 235 | }, 236 | { 237 | "key": "storageBlobName", 238 | "value": "" 239 | } 240 | ] 241 | }, 242 | "description": "The Get Blob operation reads or downloads a blob from the system, including its metadata and properties. You can also call Get Blob to read a snapshot. \n[Documentation](https://docs.microsoft.com/en-us/rest/api/storageservices/get-blob)" 243 | }, 244 | "response": [] 245 | }, 246 | { 247 | "name": "Put Blob", 248 | "request": { 249 | "method": "PUT", 250 | "header": [ 251 | { 252 | "key": "x-ms-blob-type", 253 | "value": "BlockBlob", 254 | "description": "Required. Specifies the type of blob to create: BlockBlob, PageBlob, or AppendBlob. " 255 | } 256 | ], 257 | "body": {}, 258 | "url": { 259 | "raw": "https://{{storageAccountName}}.blob.core.windows.net/:storageContainerName/:storageBlobName?sv={{storageSasTokenQueryString}}", 260 | "protocol": "https", 261 | "host": [ 262 | "{{storageAccountName}}", 263 | "blob", 264 | "core", 265 | "windows", 266 | "net" 267 | ], 268 | "path": [ 269 | ":storageContainerName", 270 | ":storageBlobName" 271 | ], 272 | "query": [ 273 | { 274 | "key": "sv", 275 | "value": "{{storageSasTokenQueryString}}", 276 | "description": "SAS token query string from Storage accounts > Shared access signature. Remove the part \"?sv=\" since this is part of the URI." 277 | } 278 | ], 279 | "variable": [ 280 | { 281 | "key": "storageContainerName", 282 | "value": "" 283 | }, 284 | { 285 | "key": "storageBlobName", 286 | "value": "" 287 | } 288 | ] 289 | }, 290 | "description": "The Put Blob operation creates a new block, page, or append blob, or updates the content of an existing block blob. \n[Documentation](https://docs.microsoft.com/en-us/rest/api/storageservices/put-blob)" 291 | }, 292 | "response": [] 293 | } 294 | ], 295 | "event": [ 296 | { 297 | "listen": "prerequest", 298 | "script": { 299 | "id": "08e920fa-7970-4bc1-b96a-3dfb0f2f49db", 300 | "type": "text/javascript", 301 | "exec": [ 302 | "" 303 | ] 304 | } 305 | }, 306 | { 307 | "listen": "test", 308 | "script": { 309 | "id": "d9c0bc27-f657-4f98-ae45-e83183f42ec4", 310 | "type": "text/javascript", 311 | "exec": [ 312 | "" 313 | ] 314 | } 315 | } 316 | ] 317 | } 318 | ], 319 | "event": [ 320 | { 321 | "listen": "prerequest", 322 | "script": { 323 | "id": "cd54c413-85bc-46e8-9a93-b3f6abe9a93a", 324 | "type": "text/javascript", 325 | "exec": [ 326 | "" 327 | ] 328 | } 329 | }, 330 | { 331 | "listen": "test", 332 | "script": { 333 | "id": "927b8013-707c-4f34-bc73-054bbaa667b7", 334 | "type": "text/javascript", 335 | "exec": [ 336 | "" 337 | ] 338 | } 339 | } 340 | ], 341 | "variable": [ 342 | { 343 | "id": "779e77c8-9fdb-448e-b924-71c52084be3e", 344 | "key": "storageAccountName", 345 | "value": "Enter here or in an environment variable", 346 | "type": "string" 347 | }, 348 | { 349 | "id": "d8c09733-958b-4167-b841-5b6194436ed5", 350 | "key": "storageSasTokenQueryString", 351 | "value": "Storage accounts > Shared access signature. Remove the part \"?sv=\" since this is part of the URI.", 352 | "type": "string" 353 | } 354 | ] 355 | } -------------------------------------------------------------------------------- /collections/AzureServiceBusMessagingAPI.postman_collection.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "_postman_id": "c8ec2bef-34a5-41fb-9e5c-236e680870c7", 4 | "name": "Azure Service Bus Messaging API", 5 | "description": "Send and receive messages using the Service Bus Messaging API. \n[Documentation ](https://docs.microsoft.com/en-us/rest/api/servicebus/service-bus-runtime-rest)", 6 | "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" 7 | }, 8 | "item": [ 9 | { 10 | "name": "Queue", 11 | "description": null, 12 | "item": [ 13 | { 14 | "name": "Receive and Delete Message", 15 | "event": [ 16 | { 17 | "listen": "prerequest", 18 | "script": { 19 | "id": "cc263b41-b4b9-46f8-bb96-ea189ec42bc4", 20 | "type": "text/javascript", 21 | "exec": [ 22 | "" 23 | ] 24 | } 25 | } 26 | ], 27 | "request": { 28 | "method": "DELETE", 29 | "header": [ 30 | { 31 | "key": "Authorization", 32 | "value": "{{sasToken}}", 33 | "description": "SAS token generated in pre-request script in collection" 34 | }, 35 | { 36 | "key": "Content-Type", 37 | "value": "application/atom+xml;type=entry;charset=utf-8" 38 | }, 39 | { 40 | "key": "BrokerProperties", 41 | "value": "null", 42 | "description": "JSON-encoded set of BrokeredMessage properties" 43 | } 44 | ], 45 | "body": { 46 | "mode": "raw", 47 | "raw": "" 48 | }, 49 | "url": { 50 | "raw": "https://{{servicebusNamespace}}.servicebus.windows.net/:queueName/messages/head", 51 | "protocol": "https", 52 | "host": [ 53 | "{{servicebusNamespace}}", 54 | "servicebus", 55 | "windows", 56 | "net" 57 | ], 58 | "path": [ 59 | ":queueName", 60 | "messages", 61 | "head" 62 | ], 63 | "variable": [ 64 | { 65 | "key": "queueName", 66 | "value": "" 67 | } 68 | ] 69 | }, 70 | "description": "This operation receives a message from a queue or subscription, and removes the message from that queue or subscription in one atomic operation. \n[Documentation](https://docs.microsoft.com/en-us/rest/api/servicebus/receive-and-delete-message-destructive-read)" 71 | }, 72 | "response": [] 73 | }, 74 | { 75 | "name": "Send Message", 76 | "event": [ 77 | { 78 | "listen": "prerequest", 79 | "script": { 80 | "id": "ddbe4407-0a04-4d8e-ab3a-486358c6514e", 81 | "type": "text/javascript", 82 | "exec": [ 83 | "" 84 | ] 85 | } 86 | } 87 | ], 88 | "request": { 89 | "method": "POST", 90 | "header": [ 91 | { 92 | "key": "Authorization", 93 | "value": "{{sasToken}}", 94 | "description": "SAS token generated in pre-request script in collection" 95 | }, 96 | { 97 | "key": "Content-Type", 98 | "value": "application/atom+xml;type=entry;charset=utf-8" 99 | }, 100 | { 101 | "key": "BrokerProperties", 102 | "value": "null", 103 | "description": "JSON-encoded set of BrokeredMessage properties" 104 | } 105 | ], 106 | "body": { 107 | "mode": "raw", 108 | "raw": "Hello World!" 109 | }, 110 | "url": { 111 | "raw": "https://{{servicebusNamespace}}.servicebus.windows.net/:queueName/messages", 112 | "protocol": "https", 113 | "host": [ 114 | "{{servicebusNamespace}}", 115 | "servicebus", 116 | "windows", 117 | "net" 118 | ], 119 | "path": [ 120 | ":queueName", 121 | "messages" 122 | ], 123 | "variable": [ 124 | { 125 | "key": "queueName", 126 | "value": "" 127 | } 128 | ] 129 | }, 130 | "description": "Sends a message to a Service Bus queue or topic. \n[Documentation](https://docs.microsoft.com/en-us/rest/api/servicebus/send-message-to-queue)" 131 | }, 132 | "response": [] 133 | }, 134 | { 135 | "name": "Peek-Lock Message", 136 | "event": [ 137 | { 138 | "listen": "prerequest", 139 | "script": { 140 | "id": "e2cffe52-d621-4747-af7e-265058a41b51", 141 | "type": "text/javascript", 142 | "exec": [ 143 | "" 144 | ] 145 | } 146 | } 147 | ], 148 | "request": { 149 | "method": "POST", 150 | "header": [ 151 | { 152 | "key": "Authorization", 153 | "value": "{{sasToken}}", 154 | "description": "SAS token generated in pre-request script in collection" 155 | }, 156 | { 157 | "key": "Content-Type", 158 | "value": "application/atom+xml;type=entry;charset=utf-8" 159 | }, 160 | { 161 | "key": "BrokerProperties", 162 | "value": "null", 163 | "description": "JSON-encoded set of BrokeredMessage properties" 164 | } 165 | ], 166 | "body": { 167 | "mode": "raw", 168 | "raw": "" 169 | }, 170 | "url": { 171 | "raw": "https://{{servicebusNamespace}}.servicebus.windows.net/:queueName/messages/head", 172 | "protocol": "https", 173 | "host": [ 174 | "{{servicebusNamespace}}", 175 | "servicebus", 176 | "windows", 177 | "net" 178 | ], 179 | "path": [ 180 | ":queueName", 181 | "messages", 182 | "head" 183 | ], 184 | "variable": [ 185 | { 186 | "key": "queueName", 187 | "value": "" 188 | } 189 | ] 190 | }, 191 | "description": "This operation atomically retrieves and locks a message from a queue or subscription for processing. \n[Documentation](https://docs.microsoft.com/en-us/rest/api/servicebus/peek-lock-message-non-destructive-read)" 192 | }, 193 | "response": [] 194 | } 195 | ], 196 | "event": [ 197 | { 198 | "listen": "prerequest", 199 | "script": { 200 | "id": "9ca824e3-6de2-4a28-9d5b-054b015f641a", 201 | "type": "text/javascript", 202 | "exec": [ 203 | "" 204 | ] 205 | } 206 | }, 207 | { 208 | "listen": "test", 209 | "script": { 210 | "id": "8f494fd7-7eef-4dc1-8c22-3e23243eb703", 211 | "type": "text/javascript", 212 | "exec": [ 213 | "" 214 | ] 215 | } 216 | } 217 | ] 218 | }, 219 | { 220 | "name": "Subscription", 221 | "description": null, 222 | "item": [ 223 | { 224 | "name": "Peek-Lock Message", 225 | "event": [ 226 | { 227 | "listen": "prerequest", 228 | "script": { 229 | "id": "e2cffe52-d621-4747-af7e-265058a41b51", 230 | "type": "text/javascript", 231 | "exec": [ 232 | "" 233 | ] 234 | } 235 | } 236 | ], 237 | "request": { 238 | "method": "POST", 239 | "header": [ 240 | { 241 | "key": "Authorization", 242 | "value": "{{sasToken}}", 243 | "description": "SAS token generated in pre-request script in collection" 244 | }, 245 | { 246 | "key": "Content-Type", 247 | "value": "application/atom+xml;type=entry;charset=utf-8" 248 | }, 249 | { 250 | "key": "BrokerProperties", 251 | "value": "null", 252 | "description": "JSON-encoded set of BrokeredMessage properties" 253 | } 254 | ], 255 | "body": { 256 | "mode": "raw", 257 | "raw": "" 258 | }, 259 | "url": { 260 | "raw": "https://{{servicebusNamespace}}.servicebus.windows.net/:topicName/subscriptions/:subscriptionName/messages/head", 261 | "protocol": "https", 262 | "host": [ 263 | "{{servicebusNamespace}}", 264 | "servicebus", 265 | "windows", 266 | "net" 267 | ], 268 | "path": [ 269 | ":topicName", 270 | "subscriptions", 271 | ":subscriptionName", 272 | "messages", 273 | "head" 274 | ], 275 | "variable": [ 276 | { 277 | "key": "topicName", 278 | "value": "" 279 | }, 280 | { 281 | "key": "subscriptionName", 282 | "value": "" 283 | } 284 | ] 285 | }, 286 | "description": "This operation atomically retrieves and locks a message from a queue or subscription for processing. \n[Documentation](https://docs.microsoft.com/en-us/rest/api/servicebus/peek-lock-message-non-destructive-read)" 287 | }, 288 | "response": [] 289 | }, 290 | { 291 | "name": "Send Message", 292 | "event": [ 293 | { 294 | "listen": "prerequest", 295 | "script": { 296 | "id": "ddbe4407-0a04-4d8e-ab3a-486358c6514e", 297 | "type": "text/javascript", 298 | "exec": [ 299 | "" 300 | ] 301 | } 302 | } 303 | ], 304 | "request": { 305 | "method": "POST", 306 | "header": [ 307 | { 308 | "key": "Authorization", 309 | "value": "{{sasToken}}", 310 | "description": "SAS token generated in pre-request script in collection" 311 | }, 312 | { 313 | "key": "Content-Type", 314 | "value": "application/atom+xml;type=entry;charset=utf-8" 315 | }, 316 | { 317 | "key": "BrokerProperties", 318 | "value": "null", 319 | "description": "JSON-encoded set of BrokeredMessage properties" 320 | } 321 | ], 322 | "body": { 323 | "mode": "raw", 324 | "raw": "Hello World!" 325 | }, 326 | "url": { 327 | "raw": "https://{{servicebusNamespace}}.servicebus.windows.net/:topicName/messages", 328 | "protocol": "https", 329 | "host": [ 330 | "{{servicebusNamespace}}", 331 | "servicebus", 332 | "windows", 333 | "net" 334 | ], 335 | "path": [ 336 | ":topicName", 337 | "messages" 338 | ], 339 | "variable": [ 340 | { 341 | "key": "topicName", 342 | "value": "" 343 | } 344 | ] 345 | }, 346 | "description": "Sends a message to a Service Bus queue or topic. \n[Documentation](https://docs.microsoft.com/en-us/rest/api/servicebus/send-message-to-queue)" 347 | }, 348 | "response": [] 349 | }, 350 | { 351 | "name": "Receive and Delete Message", 352 | "event": [ 353 | { 354 | "listen": "prerequest", 355 | "script": { 356 | "id": "e2cffe52-d621-4747-af7e-265058a41b51", 357 | "type": "text/javascript", 358 | "exec": [ 359 | "" 360 | ] 361 | } 362 | } 363 | ], 364 | "request": { 365 | "method": "DELETE", 366 | "header": [ 367 | { 368 | "key": "Authorization", 369 | "value": "{{sasToken}}", 370 | "description": "SAS token generated in pre-request script in collection" 371 | }, 372 | { 373 | "key": "Content-Type", 374 | "value": "application/atom+xml;type=entry;charset=utf-8" 375 | }, 376 | { 377 | "key": "BrokerProperties", 378 | "value": "null", 379 | "description": "JSON-encoded set of BrokeredMessage properties" 380 | } 381 | ], 382 | "body": { 383 | "mode": "raw", 384 | "raw": "" 385 | }, 386 | "url": { 387 | "raw": "https://{{servicebusNamespace}}.servicebus.windows.net/:topicName/subscriptions/:subscriptionName/messages/head", 388 | "protocol": "https", 389 | "host": [ 390 | "{{servicebusNamespace}}", 391 | "servicebus", 392 | "windows", 393 | "net" 394 | ], 395 | "path": [ 396 | ":topicName", 397 | "subscriptions", 398 | ":subscriptionName", 399 | "messages", 400 | "head" 401 | ], 402 | "variable": [ 403 | { 404 | "key": "topicName", 405 | "value": "" 406 | }, 407 | { 408 | "key": "subscriptionName", 409 | "value": "" 410 | } 411 | ] 412 | }, 413 | "description": "This operation receives a message from a queue or subscription, and removes the message from that queue or subscription in one atomic operation. \n[Documentation](https://docs.microsoft.com/en-us/rest/api/servicebus/receive-and-delete-message-destructive-read)" 414 | }, 415 | "response": [] 416 | } 417 | ], 418 | "event": [ 419 | { 420 | "listen": "prerequest", 421 | "script": { 422 | "id": "569650a0-41da-42bf-98e1-19ba1eadef06", 423 | "type": "text/javascript", 424 | "exec": [ 425 | "" 426 | ] 427 | } 428 | }, 429 | { 430 | "listen": "test", 431 | "script": { 432 | "id": "045201f4-ea25-4879-96bc-eefa6635fb78", 433 | "type": "text/javascript", 434 | "exec": [ 435 | "" 436 | ] 437 | } 438 | } 439 | ] 440 | } 441 | ], 442 | "event": [ 443 | { 444 | "listen": "prerequest", 445 | "script": { 446 | "id": "cd54c413-85bc-46e8-9a93-b3f6abe9a93a", 447 | "type": "text/javascript", 448 | "exec": [ 449 | "const servicebusNamespace = pm.variables.get(\"servicebusNamespace\");", 450 | "const namespaceUri = \"https://\"+servicebusNamespace+\".servicebus.windows.net\";", 451 | "const sasKeyName = pm.variables.get(\"sasKeyName\");", 452 | "const sasKey = pm.variables.get(\"sasKey\");", 453 | "const sasToken = createServiceBusOrEventHubsSASToken(namespaceUri, sasKeyName, sasKey);", 454 | "", 455 | "pm.variables.set(\"sasToken\", sasToken);", 456 | "", 457 | "/**", 458 | " * Create a Shared Access Signature (SAS) token valid for one minute for use with the Azure Service Bus or Event Hubs REST APIs", 459 | " * Based on https://docs.microsoft.com/en-us/rest/api/eventhub/generate-sas-token but modified to use crypto-js for compatibility with Postman", 460 | " * @param resourceUri - The full uri of the resource, e.g. https://.servicebus.windows.net", 461 | " * @param sasKeyName - The name of the Shared Access Signature key", 462 | " * @param sasKey - The Shared Access Signature key", 463 | " * @returns- A Shared Access Signature token", 464 | " * {@link https://github.com/lfalck/AzureRestApiPostmanCollections GitHub}", 465 | " * ", 466 | " */", 467 | "function createServiceBusOrEventHubsSASToken(resourceUri, sasKeyName, sasKey) {", 468 | " if (!resourceUri || !sasKeyName || !sasKey) {", 469 | " throw \"Missing required parameter\";", 470 | " }", 471 | " const encoded = encodeURIComponent(resourceUri);", 472 | " const now = new Date();", 473 | " const minute = 60;", 474 | " const ttl = Math.round(now.getTime() / 1000) + minute;", 475 | " const signature = encoded + '\\n' + ttl;", 476 | " const hash = CryptoJS.HmacSHA256(signature, sasKey).toString(CryptoJS.enc.Base64);", 477 | " return 'SharedAccessSignature sr=' + encoded + '&sig=' +", 478 | " encodeURIComponent(hash) + '&se=' + ttl + '&skn=' + sasKeyName;", 479 | "}" 480 | ] 481 | } 482 | }, 483 | { 484 | "listen": "test", 485 | "script": { 486 | "id": "927b8013-707c-4f34-bc73-054bbaa667b7", 487 | "type": "text/javascript", 488 | "exec": [ 489 | "" 490 | ] 491 | } 492 | } 493 | ], 494 | "variable": [ 495 | { 496 | "id": "32cbbc41-a52a-4e38-bd49-67aa700afae7", 497 | "key": "servicebusNamespace", 498 | "value": "Service Bus Namespace Name", 499 | "type": "string" 500 | }, 501 | { 502 | "id": "707059d1-6d49-456b-b62b-3cf4919d30b5", 503 | "key": "sasKeyName", 504 | "value": "Enter here or in an environment variable", 505 | "type": "string" 506 | }, 507 | { 508 | "id": "19828322-a1aa-46f0-8415-9c52333a0169", 509 | "key": "sasKey", 510 | "value": "Enter here or in an environment variable", 511 | "type": "string" 512 | }, 513 | { 514 | "id": "532de029-a675-4efb-9980-521d4f85b4c1", 515 | "key": "sasToken", 516 | "value": "Automatically generated in collection pre request script", 517 | "type": "string" 518 | } 519 | ] 520 | } --------------------------------------------------------------------------------