forked from Azure/azure-sdk-for-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ServiceBus] Clean up README prior to P6 with doc-owner recommendatio…
…ns. (Azure#13511) * Remove long-form samples from readme authentication section and move them into formal samples with URIs. (This by recommendation of docs folks, and supported via UX interview with user stating that the README was getting long in the teeth with this section being less critical)
- Loading branch information
1 parent
637a6da
commit 9507849
Showing
4 changed files
with
98 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
sdk/servicebus/azure-servicebus/samples/async_samples/authenticate_client_connstr_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python | ||
|
||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
""" | ||
Example to show connection-string based authentication of the ServiceBusClient. | ||
Note: To get credentials, one can either obtain the connection string from the Azure Portal, | ||
or use the Azure CLI snippet below to populate an environment variable with the service bus connection string. The following is in bash: | ||
```bash | ||
RES_GROUP=<resource-group-name> | ||
NAMESPACE_NAME=<servicebus-namespace-name> | ||
export SERVICE_BUS_CONN_STR=$(az servicebus namespace authorization-rule keys list --resource-group $RES_GROUP --namespace-name $NAMESPACE_NAME --name RootManageSharedAccessKey --query primaryConnectionString --output tsv) | ||
``` | ||
""" | ||
|
||
# pylint: disable=C0111 | ||
|
||
from azure.servicebus.aio import ServiceBusClient | ||
|
||
import os | ||
import asyncio | ||
|
||
connstr = os.environ['SERVICE_BUS_CONN_STR'] | ||
|
||
async def run(): | ||
async with ServiceBusClient.from_connection_string(connstr) as client: | ||
pass # Client is now initialized and can be used. | ||
|
||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(run()) |
31 changes: 31 additions & 0 deletions
31
sdk/servicebus/azure-servicebus/samples/sync_samples/authenticate_client_connstr.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python | ||
|
||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
""" | ||
Example to show connection-string based authentication of the ServiceBusClient. | ||
Note: To get credentials, one can either obtain the connection string from the Azure Portal, | ||
or use the Azure CLI snippet below to populate an environment variable with the service bus connection string. The following is in bash: | ||
```bash | ||
RES_GROUP=<resource-group-name> | ||
NAMESPACE_NAME=<servicebus-namespace-name> | ||
export SERVICE_BUS_CONN_STR=$(az servicebus namespace authorization-rule keys list --resource-group $RES_GROUP --namespace-name $NAMESPACE_NAME --name RootManageSharedAccessKey --query primaryConnectionString --output tsv) | ||
``` | ||
""" | ||
|
||
# pylint: disable=C0111 | ||
|
||
from azure.servicebus import ServiceBusClient | ||
|
||
import os | ||
connstr = os.environ['SERVICE_BUS_CONN_STR'] | ||
|
||
with ServiceBusClient.from_connection_string(connstr) as client: | ||
pass # Client is now initialized and can be used. | ||
|