Skip to content

Commit f96d15d

Browse files
committed
Add Python tabs
1 parent 0670306 commit f96d15d

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

articles/storage/common/multiple-identity-scenarios.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ You can also enable access to Azure resources for local development by assigning
122122
123123
#### [Java](#tab/java)
124124
125-
1. In your project, add the `azure-identity` dependency to your *pom.xml* file. This library contains all the necessary entities to implement `DefaultAzureCredential`. You can also add any other Azure dependencies that are relevant to your app. For this example, the `azure-storage-blob` and `azure-messaging-servicebus` dependencies are added to connect to Blob Storage and Service Bus.
125+
1. In your project, add the `azure-identity` dependency to your *pom.xml* file. This library provides `DefaultAzureCredential`. You can also add any other Azure dependencies that are relevant to your app. For this example, the `azure-storage-blob` and `azure-messaging-servicebus` dependencies are added to interact with Blob Storage and Service Bus.
126126
127127
```xml
128128
<dependencyManagement>
@@ -230,7 +230,7 @@ You can also enable access to Azure resources for local development by assigning
230230
231231
#### [Node.js](#tab/javascript)
232232
233-
1. In your project, use [npm](https://docs.npmjs.com/) to add a reference to the `@azure/identity` package. This library contains all of the necessary entities to implement `DefaultAzureCredential`. Install any other [Azure SDK libraries](https://www.npmjs.com/search?q=%40azure) which are relevant to your app.
233+
1. In your project, use [npm](https://docs.npmjs.com/) to add a reference to the `@azure/identity` package. This library provides `DefaultAzureCredential`. For this example, the `@azure/storage-blob` and `@azure/service-bus` packages are installed to interact with Blob Storage and Service Bus.
234234
235235
```bash
236236
npm install --save @azure/identity @azure/storage-blob @azure/service-bus
@@ -262,6 +262,40 @@ You can also enable access to Azure resources for local development by assigning
262262
);
263263
```
264264
265+
#### [Python](#tab/python)
266+
267+
1. In your project, add a reference to the `azure-identity` package. This library provides `DefaultAzureCredential`. You can also add any other Azure libraries that are relevant to your app. For this example, the `azure-storage-blob` and `azure-service-bus` packages are added to connect to Blob Storage and Service Bus, respectively.
268+
269+
```bash
270+
pip install azure-identity azure-servicebus azure-storage-blob
271+
```
272+
273+
1. Instantiate service clients for the services your app will connect to. The following code sample interacts with Blob Storage and Service Bus using the corresponding service clients.
274+
275+
```python
276+
from azure.identity import DefaultAzureCredential
277+
from azure.servicebus import ServiceBusClient, ServiceBusMessage
278+
from azure.storage.blob import BlobServiceClient
279+
import os
280+
281+
# Create an instance of DefaultAzureCredential that will use a system-assigned managed identity
282+
credential = DefaultAzureCredential()
283+
284+
blobServiceClient = BlobServiceClient(
285+
account_url="https://<my-storage-account-name>.blob.core.windows.net/",
286+
credential=credential
287+
)
288+
289+
fully_qualified_namespace = os.environ['SERVICEBUS_FULLY_QUALIFIED_NAMESPACE']
290+
queue_name = os.environ['SERVICE_BUS_QUEUE_NAME']
291+
292+
with ServiceBusClient(fully_qualified_namespace, credential) as client:
293+
with client.get_queue_sender(queue_name) as sender:
294+
# Sending a single message
295+
single_message = ServiceBusMessage("Single message")
296+
sender.send_messages(single_message)
297+
```
298+
265299
---
266300
267301
When this code runs locally, `DefaultAzureCredential` searches a credential chain for the first available credentials. If the `Managed_Identity_Client_ID` is null locally, it will automatically use the credentials from your local Azure CLI or Visual Studio sign-in. You can read more about this process in the [Azure Identity library overview](/dotnet/api/overview/azure/Identity-readme#defaultazurecredential).
@@ -530,7 +564,7 @@ public class ExampleService {
530564
}
531565
```
532566

533-
#### [Node.js](#tab/javascript)
567+
### [Node.js](#tab/javascript)
534568

535569
1. Inside of your project, use [npm](https://docs.npmjs.com/) to add a reference to the `@azure/identity` package. This library contains all of the necessary entities to implement `DefaultAzureCredential`. Install any other [Azure SDK libraries](https://www.npmjs.com/search?q=%40azure) which are relevant to your app.
536570

@@ -605,6 +639,10 @@ public class ExampleService {
605639
await sql.connect(sqlConfig);
606640
```
607641
642+
### [Python](#tab/python)
643+
644+
TODO
645+
608646
---
609647
610648
You can also associate a user-assigned managed identity and a system-assigned managed identity to a resource simultaneously. This can be useful in scenarios where all of the apps require access to the same shared services, but one of the apps also has a very specific dependency on an additional service. Using a system-assigned managed identity also ensures that the identity tied to that specific app is deleted when the app is deleted, which can help keep your environment clean.
@@ -618,4 +656,4 @@ These types of scenarios are explored in more depth in the [identities best prac
618656
In this tutorial, you learned how to migrate an application to passwordless connections. You can read the following resources to explore the concepts discussed in this article in more depth:
619657
620658
* [Authorize access to blobs using Microsoft Entra ID](../blobs/authorize-access-azure-active-directory.md)
621-
* To learn more about .NET Core, see [Get started with .NET in 10 minutes](https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/intro).
659+
* To learn more about .NET, see [Get started with .NET in 10 minutes](https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/intro).

0 commit comments

Comments
 (0)