Skip to content

Latest commit

 

History

History
61 lines (39 loc) · 3.53 KB

File metadata and controls

61 lines (39 loc) · 3.53 KB
title Create an account SAS with .NET
titleSuffix Azure Storage
description Learn how to create an account shared access signature (SAS) using the .NET client library.
services storage
author stevenmatthew
ms.service azure-storage
ms.topic how-to
ms.date 08/05/2024
ms.author shaas
ms.reviewer dineshm
ms.subservice storage-common-concepts
ms.devlang csharp
ms.custom devx-track-csharp, devguide-csharp, devx-track-dotnet

Create an account SAS with .NET

[!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.

About the account SAS

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.

Create 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":::

Use an account SAS from a client

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":::

Resources

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]

See also