Skip to content

Commit 98d4b2e

Browse files
authored
Merge pull request #286297 from pauljewellmsft/python-sas
[Dev guide] Combine SAS articles for containers and blobs - Python
2 parents 0105ce2 + 8263bd2 commit 98d4b2e

8 files changed

+91
-196
lines changed

articles/storage/.openpublishing.redirection.storage.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,16 @@
510510
"redirect_url": "/azure/storage/blobs/storage-blob-user-delegation-sas-create-java",
511511
"redirect_document_id": false
512512
},
513+
{
514+
"source_path_from_root": "/articles/storage/blobs/sas-service-create-python-container.md",
515+
"redirect_url": "/azure/storage/blobs/sas-service-create-python",
516+
"redirect_document_id": false
517+
},
518+
{
519+
"source_path_from_root": "/articles/storage/blobs/storage-blob-container-user-delegation-sas-create-python.md",
520+
"redirect_url": "/azure/storage/blobs/storage-blob-user-delegation-sas-create-python",
521+
"redirect_document_id": false
522+
},
513523
{
514524
"source_path_from_root": "/articles/storage/common/authorize-active-directory-cli.md",
515525
"redirect_url": "/azure/storage/common/authorize-data-operations-cli",

articles/storage/blobs/TOC.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,14 @@ items:
891891
href: /azure/developer/python/sdk/authentication-azure-hosted-apps?toc=/azure/storage/blobs/toc.json&bc=/azure/storage/blobs/breadcrumb/toc.json
892892
- name: Auth from on-premises apps
893893
href: /azure/developer/python/sdk/authentication-on-premises-apps?toc=/azure/storage/blobs/toc.json&bc=/azure/storage/blobs/breadcrumb/toc.json
894+
- name: Shared access signature (SAS)
895+
items:
896+
- name: Authorize using a user delegation SAS
897+
href: storage-blob-user-delegation-sas-create-python.md
898+
- name: Authorize using a service SAS
899+
href: sas-service-create-python.md
900+
- name: Authorize using an account SAS
901+
href: ../common/storage-account-sas-create-python.md?toc=/azure/storage/blobs/toc.json&bc=/azure/storage/blobs/breadcrumb/toc.json
894902
- name: Container actions
895903
items:
896904
- name: Create a container
@@ -903,14 +911,6 @@ items:
903911
href: storage-blob-container-lease-python.md
904912
- name: Manage properties and metadata
905913
href: storage-blob-container-properties-metadata-python.md
906-
- name: Generate a shared access signature (SAS)
907-
items:
908-
- name: Create a user delegation SAS for a container
909-
href: storage-blob-container-user-delegation-sas-create-python.md
910-
- name: Create a service SAS for a container
911-
href: sas-service-create-python-container.md
912-
- name: Create an account SAS
913-
href: ../common/storage-account-sas-create-python.md?toc=/azure/storage/blobs/toc.json&bc=/azure/storage/blobs/breadcrumb/toc.json
914914
- name: Blob actions
915915
items:
916916
- name: Upload blobs
@@ -937,14 +937,6 @@ items:
937937
href: storage-blob-properties-metadata-python.md
938938
- name: Set or change a blob's access tier
939939
href: storage-blob-use-access-tier-python.md
940-
- name: Generate a shared access signature (SAS)
941-
items:
942-
- name: Create a user delegation SAS for a blob
943-
href: storage-blob-user-delegation-sas-create-python.md
944-
- name: Create a service SAS for a blob
945-
href: sas-service-create-python.md
946-
- name: Create an account SAS
947-
href: ../common/storage-account-sas-create-python.md?toc=/azure/storage/blobs/toc.json&bc=/azure/storage/blobs/breadcrumb/toc.json
948940
- name: Client library configuration options
949941
items:
950942
- name: Performance tuning for uploads and downloads

articles/storage/blobs/sas-service-create-python-container.md

Lines changed: 0 additions & 61 deletions
This file was deleted.

articles/storage/blobs/sas-service-create-python.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,49 @@
11
---
2-
title: Create a service SAS for a blob with Python
2+
title: Create a service SAS for a container or blob with Python
33
titleSuffix: Azure Storage
4-
description: Learn how to create a service shared access signature (SAS) for a blob using the Azure Blob Storage client library for Python.
4+
description: Learn how to create a service shared access signature (SAS) for a container or blob using the Azure Blob Storage client library for Python.
55
author: pauljewellmsft
66

77
ms.service: azure-blob-storage
88
ms.topic: how-to
9-
ms.date: 08/05/2024
9+
ms.date: 09/06/2024
1010
ms.author: pauljewell
1111
ms.reviewer: nachakra
1212
ms.devlang: python
1313
ms.custom: devx-track-python, devguide-python, engagement-fy23
1414
---
1515

16-
# Create a service SAS for a blob with Python
16+
# Create a service SAS for a container or blob with Python
1717

1818
[!INCLUDE [storage-dev-guide-selector-service-sas](../../../includes/storage-dev-guides/storage-dev-guide-selector-service-sas.md)]
1919

2020
[!INCLUDE [storage-auth-sas-intro-include](../../../includes/storage-auth-sas-intro-include.md)]
2121

22-
This article shows how to use the storage account key to create a service SAS for a blob with the Blob Storage client library for Python.
22+
This article shows how to use the storage account key to create a service SAS for a container or blob with the Blob Storage client library for Python.
2323

2424
## About the service SAS
2525

2626
A service SAS is signed with the storage account access key. A service SAS delegates access to a resource in a single Azure Storage service, such as Blob Storage.
2727

2828
You can also use a stored access policy to define the permissions and duration of the SAS. If the name of an existing stored access policy is provided, that policy is associated with the SAS. To learn more about stored access policies, see [Define a stored access policy](/rest/api/storageservices/define-stored-access-policy). If no stored access policy is provided, the code examples in this article show how to define permissions and duration for the SAS.
2929

30-
## Create a service SAS for a blob
30+
## Create a service SAS
31+
32+
You can create a service SAS for a container or blob, based on the needs of your app.
33+
34+
### [Container](#tab/container)
35+
36+
You can create a service SAS to delegate limited access to a container resource using the following method:
37+
38+
- [generate_container_sas](/python/api/azure-storage-blob/azure.storage.blob#azure-storage-blob-generate-blob-sas)
39+
40+
The storage account access key used to sign the SAS is passed to the method as the `account_key` argument. Allowed permissions are passed to the method as the `permission` argument, and are defined in the [ContainerSasPermissions](/python/api/azure-storage-blob/azure.storage.blob.containersaspermissions) class.
41+
42+
The following code example shows how to create a service SAS with read permissions for a container resource:
43+
44+
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/blob-devguide-py/blob_devguide_create_sas.py" id="Snippet_create_service_sas_container":::
45+
46+
### [Blob](#tab/blob)
3147

3248
You can create a service SAS to delegate limited access to a blob resource using the following method:
3349

@@ -39,12 +55,26 @@ The following code example shows how to create a service SAS with read permissio
3955

4056
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/blob-devguide-py/blob_devguide_create_sas.py" id="Snippet_create_service_sas_blob":::
4157

58+
---
59+
4260
## Use a service SAS to authorize a client object
4361

62+
You can use a service SAS to authorize a client object to perform operations on a container or blob based on the permissions granted by the SAS.
63+
64+
### [Container](#tab/container)
65+
66+
The following code example shows how to use the service SAS created in the earlier example to authorize a [ContainerClient](/python/api/azure-storage-blob/azure.storage.blob.containerclient) object. This client object can be used to perform operations on the container resource based on the permissions granted by the SAS.
67+
68+
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/blob-devguide-py/blob_devguide_create_sas.py" id="Snippet_use_service_sas_container":::
69+
70+
### [Blob](#tab/blob)
71+
4472
The following code example shows how to use the service SAS created in the earlier example to authorize a [BlobClient](/python/api/azure-storage-blob/azure.storage.blob.blobclient) object. This client object can be used to perform operations on the blob resource based on the permissions granted by the SAS.
4573

4674
:::code language="python" source="~/azure-storage-snippets/blobs/howto/python/blob-devguide-py/blob_devguide_create_sas.py" id="Snippet_use_service_sas_blob":::
4775

76+
---
77+
4878
## Resources
4979

5080
To learn more about using the Azure Blob Storage client library for Python, see the following resources.

articles/storage/blobs/storage-blob-container-user-delegation-sas-create-python.md

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)