Skip to content

Commit a2822d4

Browse files
Merge pull request #286267 from pauljewellmsft/devguide-sas
[Dev guide] Combine SAS articles for containers and blobs - .NET
2 parents d94cc89 + 0df40e4 commit a2822d4

6 files changed

+93
-152
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,16 @@
490490
"redirect_url": "/azure/storage/blobs/storage-quickstart-blobs-xamarin",
491491
"redirect_document_id": false
492492
},
493+
{
494+
"source_path_from_root": "/articles/storage/blobs/sas-service-create-dotnet-container.md",
495+
"redirect_url": "/azure/storage/blobs/sas-service-create-dotnet",
496+
"redirect_document_id": false
497+
},
498+
{
499+
"source_path_from_root": "/articles/storage/blobs/storage-blob-container-user-delegation-sas-create-dotnet.md",
500+
"redirect_url": "/azure/storage/blobs/storage-blob-user-delegation-sas-create-dotnet",
501+
"redirect_document_id": false
502+
},
493503
{
494504
"source_path_from_root": "/articles/storage/common/authorize-active-directory-cli.md",
495505
"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
@@ -585,6 +585,14 @@ items:
585585
href: /dotnet/azure/sdk/authentication-azure-hosted-apps?toc=/azure/storage/blobs/toc.json&bc=/azure/storage/blobs/breadcrumb/toc.json
586586
- name: Auth from on-premises apps
587587
href: /dotnet/azure/sdk/authentication-on-premises-apps?toc=/azure/storage/blobs/toc.json&bc=/azure/storage/blobs/breadcrumb/toc.json
588+
- name: Shared access signature (SAS)
589+
items:
590+
- name: Authorize using a user delegation SAS
591+
href: storage-blob-user-delegation-sas-create-dotnet.md
592+
- name: Authorize using a service SAS
593+
href: sas-service-create-dotnet.md
594+
- name: Authorize using an account SAS
595+
href: ../common/storage-account-sas-create-dotnet.md?toc=/azure/storage/blobs/toc.json&bc=/azure/storage/blobs/breadcrumb/toc.json
588596
- name: Container actions
589597
items:
590598
- name: Create a container
@@ -597,14 +605,6 @@ items:
597605
href: storage-blob-container-lease.md
598606
- name: Manage properties and metadata
599607
href: storage-blob-container-properties-metadata.md
600-
- name: Generate a shared access signature (SAS)
601-
items:
602-
- name: Create a user delegation SAS for a container
603-
href: storage-blob-container-user-delegation-sas-create-dotnet.md
604-
- name: Create a service SAS for a container
605-
href: sas-service-create-dotnet-container.md
606-
- name: Create an account SAS
607-
href: ../common/storage-account-sas-create-dotnet.md?toc=/azure/storage/blobs/toc.json&bc=/azure/storage/blobs/breadcrumb/toc.json
608608
- name: Blob actions
609609
items:
610610
- name: Upload blobs
@@ -635,14 +635,6 @@ items:
635635
href: versions-manage-dotnet.md
636636
- name: Set or change a blob's access tier
637637
href: storage-blob-use-access-tier-dotnet.md
638-
- name: Generate a shared access signature (SAS)
639-
items:
640-
- name: Create a user delegation SAS for a blob
641-
href: storage-blob-user-delegation-sas-create-dotnet.md
642-
- name: Create a service SAS for a blob
643-
href: sas-service-create-dotnet.md
644-
- name: Create an account SAS
645-
href: ../common/storage-account-sas-create-dotnet.md?toc=/azure/storage/blobs/toc.json&bc=/azure/storage/blobs/breadcrumb/toc.json
646638
- name: Append blob actions
647639
items:
648640
- name: Append data to an append blob

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

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

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

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,68 @@
11
---
22
title: Create a service SAS for a blob with .NET
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 .NET.
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 .NET.
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: csharp
1313
ms.custom: devx-track-csharp, devguide-csharp, engagement-fy23, devx-track-dotnet
1414
---
1515

16-
# Create a service SAS for a blob with .NET
16+
# Create a service SAS for a container or blob with .NET
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 Azure Blob Storage client library for .NET.
22+
This article shows how to use the storage account key to create a service SAS for a container or blob with the Azure Blob Storage client library for .NET.
2323

2424
## About the service SAS
2525

2626
A service SAS is signed with the account access key. You can use the [StorageSharedKeyCredential](/dotnet/api/azure.storage.storagesharedkeycredential) class to create the credential that is used to sign the service SAS.
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](#define-a-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+
The following code example shows how to create a service SAS for a container resource. First, the code verifies that the [BlobContainerClient](/dotnet/api/azure.storage.blobs.blobcontainerclient) object is authorized with a shared key credential by checking the [CanGenerateSasUri](/dotnet/api/azure.storage.blobs.blobcontainerclient.cangeneratesasuri) property. Then, it generates the service SAS via the [BlobSasBuilder](/dotnet/api/azure.storage.sas.blobsasbuilder) class, and calls [GenerateSasUri](/dotnet/api/azure.storage.blobs.blobcontainerclient.generatesasuri) to create a service SAS URI based on the client and builder objects.
37+
38+
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/BlobDevGuideBlobs/CreateSas.cs" id="Snippet_CreateServiceSASContainer":::
39+
40+
### [Blob](#tab/blob)
3141

3242
The following code example shows how to create a service SAS for a blob resource. First, the code verifies that the [BlobClient](/dotnet/api/azure.storage.blobs.blobclient) object is authorized with a shared key credential by checking the [CanGenerateSasUri](/dotnet/api/azure.storage.blobs.specialized.blobbaseclient.cangeneratesasuri#azure-storage-blobs-specialized-blobbaseclient-cangeneratesasuri) property. Then, it generates the service SAS via the [BlobSasBuilder](/dotnet/api/azure.storage.sas.blobsasbuilder) class, and calls [GenerateSasUri](/dotnet/api/azure.storage.blobs.specialized.blobbaseclient.generatesasuri#azure-storage-blobs-specialized-blobbaseclient-generatesasuri(azure-storage-sas-blobsasbuilder)) to create a service SAS URI based on the client and builder objects.
3343

3444
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/BlobDevGuideBlobs/CreateSas.cs" id="Snippet_CreateServiceSASBlob":::
3545

46+
---
47+
3648
## Use a service SAS to authorize a client object
3749

50+
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.
51+
52+
### [Container](#tab/container)
53+
54+
The following code examples show how to use the service SAS to authorize a [BlobContainerClient](/dotnet/api/azure.storage.blobs.blobcontainerclient) object. This client object can be used to perform operations on the container resource based on the permissions granted by the SAS.
55+
56+
First, create a [BlobServiceClient](/dotnet/api/azure.storage.blobs.blobserviceclient) object signed with the account access key:
57+
58+
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/BlobDevGuideBlobs/CreateSas.cs" id="Snippet_CreateServiceClientSharedKey":::
59+
60+
Then, generate the service SAS as shown in the earlier example and use the SAS to authorize a [BlobContainerClient](/dotnet/api/azure.storage.blobs.blobcontainerclient) object:
61+
62+
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/BlobDevGuideBlobs/CreateSas.cs" id="Snippet_UseServiceSASContainer":::
63+
64+
### [Blob](#tab/blob)
65+
3866
The following code example shows how to use the service SAS to authorize a [BlobClient](/dotnet/api/azure.storage.blobs.blobclient) object. This client object can be used to perform operations on the blob resource based on the permissions granted by the SAS.
3967

4068
First, create a [BlobServiceClient](/dotnet/api/azure.storage.blobs.blobserviceclient) object signed with the account access key:
@@ -45,16 +73,21 @@ Then, generate the service SAS as shown in the earlier example and use the SAS t
4573

4674
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/BlobDevGuideBlobs/CreateSas.cs" id="Snippet_UseServiceSASBlob":::
4775

76+
---
77+
4878
[!INCLUDE [storage-dev-guide-stored-access-policy](../../../includes/storage-dev-guides/storage-dev-guide-stored-access-policy.md)]
4979

5080
## Resources
5181

5282
To learn more about creating a service SAS using the Azure Blob Storage client library for .NET, see the following resources.
5383

84+
### Code samples
85+
86+
- [View code samples from this article (GitHub)](https://github.com/Azure-Samples/AzureStorageSnippets/blob/master/blobs/howto/dotnet/BlobDevGuideBlobs/CreateSAS.cs)
87+
5488
[!INCLUDE [storage-dev-guide-resources-dotnet](../../../includes/storage-dev-guides/storage-dev-guide-resources-dotnet.md)]
5589

5690
### See also
5791

5892
- [Grant limited access to Azure Storage resources using shared access signatures (SAS)](../common/storage-sas-overview.md)
5993
- [Create a service SAS](/rest/api/storageservices/create-service-sas)
60-
- For related code samples using deprecated .NET version 11.x SDKs, see [Code samples using .NET version 11.x](blob-v11-samples-dotnet.md#create-a-service-sas-for-a-blob-container).

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

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

0 commit comments

Comments
 (0)