|
1 | 1 | --- |
2 | 2 | title: "Service Bus Data Plane" |
3 | | -description: API coverage for Microsoft.ServiceBus.DataPlane in LocalStack for Azure. |
| 3 | +description: Get started with Azure Service Bus Data Plane on LocalStack |
4 | 4 | template: doc |
5 | 5 | --- |
6 | 6 |
|
7 | 7 | import AzureFeatureCoverage from "../../../../components/feature-coverage/AzureFeatureCoverage"; |
8 | 8 |
|
| 9 | +## Introduction |
| 10 | + |
| 11 | +Azure Service Bus Data Plane APIs let you operate messaging entities through the namespace endpoint directly. |
| 12 | +These APIs are useful for programmatic queue, topic, and subscription operations in integration and messaging workflows. |
| 13 | +In LocalStack, they are useful for validating data-plane behavior without calling Azure cloud endpoints. |
| 14 | + |
| 15 | +LocalStack for Azure provides a local environment for building and testing applications that make use of Azure Service Bus Data Plane APIs. |
| 16 | +The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of Service Bus Data Plane integration with LocalStack. |
| 17 | + |
| 18 | +## Getting started |
| 19 | + |
| 20 | +This guide is designed for users new to Service Bus Data Plane APIs and assumes basic knowledge of the Azure CLI and our `azlocal` wrapper script. |
| 21 | + |
| 22 | +Start your LocalStack container using your preferred method. For more information, see [Introduction to LocalStack for Azure](/azure/getting-started/). |
| 23 | + |
| 24 | +:::note |
| 25 | +As an alternative to using the `azlocal` CLI, users can run: |
| 26 | + |
| 27 | +`azlocal start-interception` |
| 28 | + |
| 29 | +This command points the `az` CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator API. |
| 30 | +To revert this configuration, run: |
| 31 | + |
| 32 | +`azlocal stop-interception` |
| 33 | + |
| 34 | +This reconfigures the `az` CLI to send commands to the official Azure management REST API. At this time, there is no full parity between `azlocal` and `az` commands after running `az start-interception`. Therefore, this technique is not fully interchangeable. |
| 35 | +::: |
| 36 | + |
| 37 | +### Create a resource group |
| 38 | + |
| 39 | +Create a resource group for your Service Bus resources: |
| 40 | + |
| 41 | +```bash |
| 42 | +azlocal group create \ |
| 43 | + --name rg-servicebus-dp-demo \ |
| 44 | + --location westeurope |
| 45 | +``` |
| 46 | + |
| 47 | +```bash title="Output" |
| 48 | +{ |
| 49 | + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-servicebus-dp-demo", |
| 50 | + "location": "westeurope", |
| 51 | + "name": "rg-servicebus-dp-demo", |
| 52 | + "properties": { |
| 53 | + "provisioningState": "Succeeded" |
| 54 | + }, |
| 55 | + ... |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +### Create a Service Bus namespace |
| 60 | + |
| 61 | +Create a namespace and capture its data-plane endpoint: |
| 62 | + |
| 63 | +```bash |
| 64 | +azlocal servicebus namespace create \ |
| 65 | + --resource-group rg-servicebus-dp-demo \ |
| 66 | + --name sbnsdoc84 \ |
| 67 | + --location westeurope \ |
| 68 | + --sku Standard |
| 69 | +``` |
| 70 | + |
| 71 | +```bash title="Output" |
| 72 | +{ |
| 73 | + "name": "sbnsdoc84", |
| 74 | + "serviceBusEndpoint": "https://sbnsdoc84.localhost.localstack.cloud:4511", |
| 75 | + "provisioningState": "Succeeded", |
| 76 | + ... |
| 77 | +} |
| 78 | +``` |
| 79 | + |
| 80 | +Store the HTTP endpoint for data-plane REST calls: |
| 81 | + |
| 82 | +```bash |
| 83 | +SB_ENDPOINT="http://sbnsdoc84.localhost.localstack.cloud:4511" |
| 84 | +``` |
| 85 | + |
| 86 | +### Create and inspect a queue entity |
| 87 | + |
| 88 | +Create a queue via the data-plane Entity `Put` API: |
| 89 | + |
| 90 | +```bash |
| 91 | +curl -s -X PUT "$SB_ENDPOINT/dpqueue?api-version=2017-04" \ |
| 92 | + -H "Content-Type: application/atom+xml;type=entry;charset=utf-8" \ |
| 93 | + -d '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom"><title type="text">dpqueue</title><content type="application/xml"><QueueDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" /></content></entry>' |
| 94 | +``` |
| 95 | + |
| 96 | +```xml title="Output" |
| 97 | +<?xml version="1.0" encoding="utf-8"?> |
| 98 | +<entry xmlns="http://www.w3.org/2005/Atom"> |
| 99 | + <title type="text">dpqueue</title> |
| 100 | + <content type="application/xml"> |
| 101 | + <QueueDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> |
| 102 | + <Status>Active</Status> |
| 103 | + ... |
| 104 | + </QueueDescription> |
| 105 | + </content> |
| 106 | +</entry> |
| 107 | +``` |
| 108 | + |
| 109 | +Get the queue entity via Entity `Get`: |
| 110 | + |
| 111 | +```bash |
| 112 | +curl -s -X GET "$SB_ENDPOINT/dpqueue?api-version=2017-04" |
| 113 | +``` |
| 114 | + |
| 115 | +```xml title="Output" |
| 116 | +<?xml version="1.0" encoding="utf-8"?> |
| 117 | +<entry xmlns="http://www.w3.org/2005/Atom"> |
| 118 | + <title type="text">dpqueue</title> |
| 119 | + <content type="application/xml"> |
| 120 | + <QueueDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> |
| 121 | + <MessageCount>0</MessageCount> |
| 122 | + <Status>Active</Status> |
| 123 | + ... |
| 124 | + </QueueDescription> |
| 125 | + </content> |
| 126 | +</entry> |
| 127 | +``` |
| 128 | + |
| 129 | +### Create and inspect a topic subscription |
| 130 | + |
| 131 | +Create a topic entity: |
| 132 | + |
| 133 | +```bash |
| 134 | +curl -s -X PUT "$SB_ENDPOINT/dptopic?api-version=2017-04" \ |
| 135 | + -H "Content-Type: application/atom+xml;type=entry;charset=utf-8" \ |
| 136 | + -d '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom"><title type="text">dptopic</title><content type="application/xml"><TopicDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" /></content></entry>' |
| 137 | +``` |
| 138 | + |
| 139 | +Create a subscription via Subscription `Put`: |
| 140 | + |
| 141 | +```bash |
| 142 | +curl -s -X PUT "$SB_ENDPOINT/dptopic/subscriptions/dpsub?api-version=2017-04" \ |
| 143 | + -H "Content-Type: application/atom+xml;type=entry;charset=utf-8" \ |
| 144 | + -d '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom"><title type="text">dpsub</title><content type="application/xml"><SubscriptionDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" /></content></entry>' |
| 145 | +``` |
| 146 | + |
| 147 | +```xml title="Output" |
| 148 | +<?xml version="1.0" encoding="utf-8"?> |
| 149 | +<entry xmlns="http://www.w3.org/2005/Atom"> |
| 150 | + <title type="text">dpsub</title> |
| 151 | + <content type="application/xml"> |
| 152 | + <SubscriptionDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> |
| 153 | + <Status>Active</Status> |
| 154 | + <MaxDeliveryCount>10</MaxDeliveryCount> |
| 155 | + ... |
| 156 | + </SubscriptionDescription> |
| 157 | + </content> |
| 158 | +</entry> |
| 159 | +``` |
| 160 | + |
| 161 | +Get the subscription via Subscription `Get`: |
| 162 | + |
| 163 | +```bash |
| 164 | +curl -s -X GET "$SB_ENDPOINT/dptopic/subscriptions/dpsub?api-version=2017-04" |
| 165 | +``` |
| 166 | + |
| 167 | +```xml title="Output" |
| 168 | +<?xml version="1.0" encoding="utf-8"?> |
| 169 | +<entry xmlns="http://www.w3.org/2005/Atom"> |
| 170 | + <title type="text">dpsub</title> |
| 171 | + <content type="application/xml"> |
| 172 | + <SubscriptionDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> |
| 173 | + <MessageCount>0</MessageCount> |
| 174 | + <Status>Active</Status> |
| 175 | + ... |
| 176 | + </SubscriptionDescription> |
| 177 | + </content> |
| 178 | +</entry> |
| 179 | +``` |
| 180 | + |
| 181 | +### Delete subscription and entities |
| 182 | + |
| 183 | +Delete the subscription via Subscription `Delete`: |
| 184 | + |
| 185 | +```bash |
| 186 | +curl -s -X DELETE "$SB_ENDPOINT/dptopic/subscriptions/dpsub?api-version=2017-04" |
| 187 | +``` |
| 188 | + |
| 189 | +Delete entities via Entity `Delete`: |
| 190 | + |
| 191 | +```bash |
| 192 | +curl -s -X DELETE "$SB_ENDPOINT/dptopic?api-version=2017-04" |
| 193 | + |
| 194 | +curl -s -X DELETE "$SB_ENDPOINT/dpqueue?api-version=2017-04" |
| 195 | +``` |
| 196 | + |
9 | 197 | ## API Coverage |
10 | 198 |
|
11 | 199 | <AzureFeatureCoverage service="Microsoft.ServiceBus.DataPlane" client:load /> |
0 commit comments