title | titleSuffix | description | services | author | ms.service | ms.topic | ms.date | ms.author | ms.reviewer | ms.subservice | ms.devlang | ms.custom |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Create an account SAS with .NET |
Azure Storage |
Learn how to create an account shared access signature (SAS) using the .NET client library. |
storage |
pauljewellmsft |
azure-storage |
how-to |
09/21/2023 |
pauljewell |
dineshm |
storage-common-concepts |
csharp |
devx-track-csharp, devguide-csharp, devx-track-dotnet |
[!INCLUDE storage-dev-guide-selector-account-sas]
[!INCLUDE storage-auth-sas-intro-include]
This article shows how to use the storage account key to create an account SAS with the Azure Storage client library for .NET.
An account SAS is created at the level of the storage account. By creating an account SAS, you can:
- Delegate access to service-level operations that aren't currently available with a service-specific SAS, such as Get Blob Service Properties, Set Blob Service Properties and Get Blob Service Stats.
- Delegate access to more than one service in a storage account at a time. For example, you can delegate access to resources in both Azure Blob Storage and Azure Files by using an account SAS.
Stored access policies aren't supported for an account SAS.
An account SAS is signed with the account access key. You can use the StorageSharedKeyCredential class to create the credential that is used to sign the SAS.
The following code example shows how to create a new AccountSasBuilder object and call the ToSasQueryParameters method to get the account SAS token string.
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/BlobDevGuideBlobs/CreateSas.cs" id="Snippet_CreateAccountSAS":::
To use the account SAS to access service-level APIs for the Blob service, create a BlobServiceClient object using the account SAS and the Blob Storage endpoint for your storage account.
:::code language="csharp" source="~/azure-storage-snippets/blobs/howto/dotnet/BlobDevGuideBlobs/CreateSas.cs" id="Snippet_UseAccountSAS":::
To learn more about creating an account SAS using the Azure Blob Storage client library for .NET, see the following resources.
[!INCLUDE storage-dev-guide-resources-dotnet]
- Grant limited access to Azure Storage resources using shared access signatures (SAS)
- Create an account SAS
- For related code samples using deprecated .NET version 11.x SDKs, see Code samples using .NET version 11.x.