Skip to content

Commit b12a6ce

Browse files
authored
Merge pull request #303254 from DespindolaMS/docs-editor/sas-expiration-policy-1753366847
Update sas-expiration-policy.md
2 parents af8585e + cf40fe5 commit b12a6ce

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed
154 KB
Loading

articles/storage/common/sas-expiration-policy.md

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author: pauljewellmsft
77
ms.author: pauljewell
88
ms.service: azure-storage
99
ms.topic: how-to
10-
ms.date: 07/29/2024
10+
ms.date: 07/30/2025
1111
ms.reviewer: nachakra
1212
ms.subservice: storage-common-concepts
1313
ms.custom: engagement-fy23
@@ -16,7 +16,7 @@ ms.custom: engagement-fy23
1616

1717
# Configure an expiration policy for shared access signatures
1818

19-
You can use a shared access signature (SAS) to delegate access to resources in your Azure Storage account. A SAS token includes the targeted resource, the permissions granted, and the interval over which access is permitted. Best practices recommend that you limit the interval for a SAS in case it's compromised. By setting a SAS expiration policy for your storage accounts, you can provide a recommended upper expiration limit when a user creates a user delegation SAS, a service SAS, or an account SAS.
19+
You can use a shared access signature (SAS) to delegate access to resources in your Azure Storage account. A SAS token includes the targeted resource, the permissions granted, and the interval over which access is permitted. Best practices recommend that you limit the interval for a SAS in case it's compromised. By setting a SAS expiration policy for your storage accounts, you can recommend or enforce an upper expiration limit (maximum validity interval) when a user creates a user delegation SAS, a service SAS, or an account SAS.
2020

2121
For more information about shared access signatures, see [Grant limited access to Azure Storage resources using shared access signatures (SAS)](storage-sas-overview.md).
2222

@@ -25,15 +25,28 @@ For more information about shared access signatures, see [Grant limited access t
2525
2626
## About SAS expiration policies
2727

28-
You can configure a SAS expiration policy on the storage account. The SAS expiration policy specifies the recommended upper limit for the signed expiry field on a user delegation SAS, a service SAS, or an account SAS. The recommended upper limit is specified as a date/time value that is a combined number of days, hours, minutes, and seconds.
28+
You can configure a SAS expiration policy on the storage account. The SAS expiration policy specifies the upper limit for the validity interval on a user delegation SAS, a service SAS, or an account SAS. The upper limit is specified as a date/time value that is a combined number of days, hours, minutes, and seconds.
2929

3030
The validity interval for the SAS is calculated by subtracting the date/time value of the signed start field from the date/time value of the signed expiry field. If the resulting value is less than or equal to the recommended upper limit, then the SAS is in compliance with the SAS expiration policy.
3131

32-
After you configure the SAS expiration policy, any user who creates a SAS with an interval that exceeds the recommended upper limit will see a warning.
32+
When a SAS expiration policy is in effect for the storage account, the signed start field is required for every SAS. If the signed start field isn't included on the SAS, and you've configured a diagnostic setting for logging with Azure Monitor, then Azure Storage writes a message to the **SasExpiryStatus** property in the logs whenever a user *uses* a SAS without a value for the signed start field.
3333

34-
A SAS expiration policy doesn't prevent a user from creating a SAS with an expiration that exceeds the limit recommended by the policy. When a user creates a SAS that violates the policy, they see a warning, along with the recommended maximum interval. If you've configured a diagnostic setting for logging with Azure Monitor, then Azure Storage writes a message to the **SasExpiryStatus** property in the logs whenever a user *uses* a SAS that expires after the recommended interval. The message indicates that the validity interval of the SAS exceeds the recommended interval.
34+
After you configure the SAS expiration policy, any user who creates a SAS with an interval that exceeds the recommended upper limit will see a warning, along with the recommended maximum interval.
3535

36-
When a SAS expiration policy is in effect for the storage account, the signed start field is required for every SAS. If the signed start field isn't included on the SAS, and you've configured a diagnostic setting for logging with Azure Monitor, then Azure Storage writes a message to the **SasExpiryStatus** property in the logs whenever a user *uses* a SAS without a value for the signed start field.
36+
## Define the SAS Expiration Action
37+
38+
SAS expiration policy supports two actions: 
39+
40+
- **[Default] Log:** Requests made with out-of-policy SAS are allowed. If you've configured a diagnostic setting for logging with Azure Monitor, then Azure Storage writes a message to the **SasExpiryStatus** property in the logs whenever a user *uses* a SAS that expires after the recommended interval. The message indicates that the validity interval of the SAS exceeds the recommended interval. This option is recommended for monitoring and auditing access without disrupting workflows. 
41+
42+
- **Block:** Requests made with out-of-policy SAS are denied. This is your strictest option for enforcing access controls in line with your organizational requirements. 
43+
44+
Out-of-policy SAS are those which do not have a signed start or have a validity interval larger than the upper limit.
45+
46+
Start by reviewing your current SAS token usage and setting an appropriate expiration policy for your storage accounts. We recommend starting with **Log** action to monitor your diagnostic logs for policy violations. We strongly recommend using **Block** action to ensure that if a SAS token has passed the validity of the expiration period set on the storage account, then access to storage must be blocked.
47+
48+
> [!IMPORTANT]
49+
> SAS Expiration Action is not supported for user delegation SAS through the HDFS endpoint or service-level shared access signatures with a stored access policy.
3750
3851
## Configure a SAS expiration policy
3952

@@ -58,27 +71,31 @@ To configure a SAS expiration policy in the Azure portal, follow these steps:
5871

5972
1. Navigate to your storage account in the Azure portal.
6073
1. Under **Settings**, select **Configuration**.
61-
1. Locate the setting for **Allow recommended upper limit for shared access signature (SAS) expiry interval**, and set it to **Enabled**.
74+
1. Locate the setting for **Shared access signature (SAS) expiration policy**, and set it to **Enabled**.
6275

63-
> [!NOTE]
64-
> If the setting is grayed out and you see the message shown in the image below, then [you will need to rotate both account access keys](#do-i-need-to-rotate-the-account-access-keys-first) before you can set the **Recommended upper limit for SAS expiry interval** values:
65-
>
66-
> :::image type="content" source="media/sas-expiration-policy/configure-sas-expiration-policy-portal-grayed-out.png" alt-text="Screenshot showing the option to configure a SAS expiration policy is grayed out in the Azure portal." lightbox="media/sas-expiration-policy/configure-sas-expiration-policy-portal-grayed-out.png":::
76+
> [!NOTE]
77+
> If the setting is grayed out, [you may need to rotate both account access keys](#do-i-need-to-rotate-the-account-access-keys-first) before you can set an expiration policy.
78+
>
79+
80+
1. Specify a time value under **Upper limit for SAS expiry interval** for the desired maximum interval for new shared access signatures that are created on resources in this storage account.
6781

68-
1. Specify the time values under **Recommended upper limit for SAS expiry interval** for the recommended interval for any new shared access signatures that are created on resources in this storage account.
69-
70-
:::image type="content" source="media/sas-expiration-policy/configure-sas-expiration-policy-portal.png" alt-text="Screenshot showing how to configure a SAS expiration policy in the Azure portal." lightbox="media/sas-expiration-policy/configure-sas-expiration-policy-portal.png":::
82+
1. [Optional] Define the expiration action. The default **Log** action helps you detect trends and investigate access without disrupting users, while **Block** action lets you enforce zero-tolerance for out-of-policy SAS tokens.
7183

7284
1. Select **Save** to save your changes.
7385

86+
:::image type="content" source="media/sas-expiration-policy/policy-portal-configuration.jpeg" alt-text="Screenshot showing how to configure a SAS expiration policy in the Azure portal." lightbox="media/sas-expiration-policy/policy-portal-configuration.jpeg":::
87+
7488
#### [PowerShell](#tab/azure-powershell)
7589

7690
To configure a SAS expiration policy, use the [Set-AzStorageAccount](/powershell/module/az.storage/set-azstorageaccount) command, and then set the `-SasExpirationPeriod` parameter to the number of days, hours, minutes, and seconds that a SAS token can be active from the time that a SAS is signed. The string that you provide the `-SasExpirationPeriod` parameter uses the following format: `<days>.<hours>:<minutes>:<seconds>`. For example, if you wanted the SAS to expire 1 day, 12 hours, 5 minutes, and 6 seconds after it's signed, then you would use the string `1.12:05:06`.
7791

92+
[Optional] Set the `-SasExpirationAction` parameter to the desired action for out-of-policy SAS. Acceptable values include **Log** or **Block**.
93+
7894
```powershell
7995
$account = Set-AzStorageAccount -ResourceGroupName <resource-group> `
8096
-Name <storage-account-name> `
8197
-SasExpirationPeriod <days>.<hours>:<minutes>:<seconds>
98+
-SasExpirationAction <action>
8299
```
83100

84101
> [!TIP]
@@ -102,11 +119,14 @@ The SAS expiration period appears in the console output.
102119

103120
To configure a SAS expiration policy, use the [az storage account update](/cli/azure/storage/account#az-storage-account-update) command, and then set the `--key-exp-days` parameter to the number of days, hours, minutes, and seconds that a SAS token can be active from the time that a SAS is signed. The string that you provide the `--key-exp-days` parameter uses the following format: `<days>.<hours>:<minutes>:<seconds>`. For example, if you wanted the SAS to expire 1 day, 12 hours, 5 minutes, and 6 seconds after it's signed, then you would use the string `1.12:05:06`.
104121

122+
[Optional] Set the `--sas-expiration-action` parameter to the desired action for out-of-policy SAS. Acceptable values include **Log** or **Block**.
123+
105124
```azurecli-interactive
106125
az storage account update \
107126
--name <storage-account> \
108127
--resource-group <resource-group> \
109128
--sas-exp <days>.<hours>:<minutes>:<seconds>
129+
--sas-expiration-action <action>
110130
```
111131

112132
> [!TIP]
@@ -186,3 +206,4 @@ To bring a storage account into compliance, configure a SAS expiration policy fo
186206
- [Grant limited access to Azure Storage resources using shared access signatures (SAS)](storage-sas-overview.md)
187207
- [Create a service SAS](/rest/api/storageservices/create-service-sas)
188208
- [Create an account SAS](/rest/api/storageservices/create-account-sas)
209+

0 commit comments

Comments
 (0)