You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from azure.core.exceptions import ResourceExistsError
36
+
from azure.identity import DefaultAzureCredential
37
+
from azure.storage.blob import BlobServiceClient
38
+
```
39
+
30
40
#### Authorization
31
41
32
42
The authorization mechanism must have the necessary permissions to create a container. For authorization with Microsoft Entra ID (recommended), you need Azure RBAC built-in role **Storage Blob Data Contributor** or higher. To learn more, see the authorization guidance for [Create Container (REST API)](/rest/api/storageservices/create-container#authorization).
To connect an app to Blob Storage, create an instance of [BlobServiceClient](/python/api/azure-storage-blob/azure.storage.blob.blobserviceclient). The following example shows how to create a client object using `DefaultAzureCredential` for authorization:
You can also create client objects for specific [containers](../../articles/storage/blobs/storage-blob-client-management.md#create-a-blobcontainerclient-object) or [blobs](../../articles/storage/blobs/storage-blob-client-management.md#create-a-blobclient-object). To learn more about creating and managing client objects, see [Create and manage client objects that interact with data resources](../../articles/storage/blobs/storage-blob-client-management.md).
Copy file name to clipboardExpand all lines: includes/storage-dev-guides/storage-dev-guide-project-setup-python.md
+4-31Lines changed: 4 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,42 +10,15 @@ ms.author: pauljewell
10
10
ms.custom: include file
11
11
---
12
12
13
-
If you don't have an existing project, this section shows you how to set up a project to work with the Azure Blob Storage client library for Python. The steps include package installation, adding `import` statements, and creating an authorized client object. For details, see [Get started with Azure Blob Storage and Python](../../articles/storage/blobs/storage-blob-python-get-started.md).
13
+
If you don't have an existing project, this section shows you how to set up a project to work with the Azure Blob Storage client library for Python. For more details, see [Get started with Azure Blob Storage and Python](../../articles/storage/blobs/storage-blob-python-get-started.md).
14
+
15
+
To work with the code examples in this article, follow these steps to set up your project.
14
16
15
17
#### Install packages
16
18
17
-
From your project directory, install packages for the Azure Blob Storage and Azure Identity client libraries using the `pip install` command. The **azure-identity** package is needed for passwordless connections to Azure services.
19
+
Install the following packages using `pip install`:
18
20
19
21
```console
20
22
pip install azure-storage-blob azure-identity
21
23
```
22
24
23
-
#### Add `import` statements
24
-
25
-
Add these `import` statements to your code file:
26
-
27
-
```python
28
-
from azure.identity import DefaultAzureCredential
29
-
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
30
-
```
31
-
32
-
Some code examples in this article might require additional `import` statements.
33
-
34
-
#### Create a client object
35
-
36
-
To connect an app to Blob Storage, create an instance of [BlobServiceClient](/python/api/azure-storage-blob/azure.storage.blob.blobserviceclient). The following example shows how to create a client object using `DefaultAzureCredential` for authorization:
You can also create client objects for specific [containers](../../articles/storage/blobs/storage-blob-client-management.md#create-a-blobcontainerclient-object) or [blobs](../../articles/storage/blobs/storage-blob-client-management.md#create-a-blobclient-object). To learn more about creating and managing client objects, see [Create and manage client objects that interact with data resources](../../articles/storage/blobs/storage-blob-client-management.md).
0 commit comments