# Storage SAS tokens should adhere to 7 day maximum validity

Facts read 10 Nov 2026. Page reviewed 16 Nov 2026.

Storage SAS tokens should adhere to 7 day maximum validity is an Azure guardrail written in Azure Policy. Denies storage accounts whose SAS expiration policy allows tokens valid for more than 7 days, which limits how long a leaked token can move data out.

```text
Built-in policy definition: Storage SAS tokens should adhere to 7 day maximum validity
Definition ID: 7aa1c9d5-3d7e-4579-8117-d85e99211757
Category: Storage
Supported effects: Audit, Deny, Disabled
policyRule (copied from the repository file):
{
    "if": {
      "allOf": [
        {
          "field": "type",
          "equals": "Microsoft.Storage/storageAccounts"
        },
        {
          "anyOf": [
            {
              "field": "Microsoft.Storage/storageAccounts/sasPolicy",
              "exists": "false"
            },
            {
              "field": "Microsoft.Storage/storageAccounts/sasPolicy.sasExpirationPeriod",
              "exists": "false"
            },
            {
              "value": "[if(empty(field('Microsoft.Storage/storageAccounts/sasPolicy.sasExpirationPeriod')), 99, int(split(field('Microsoft.Storage/storageAccounts/sasPolicy.sasExpirationPeriod'), createArray(':', '.'))[0]))]",
              "greater": 7
            },
            {
              "allOf": [
                {
                  "value": "[if(empty(field('Microsoft.Storage/storageAccounts/sasPolicy.sasExpirationPeriod')), 0, int(split(field('Microsoft.Storage/storageAccounts/sasPolicy.sasExpirationPeriod'), createArray(':', '.'))[0]))]",
                  "equals": 7
                },
                {
                  "anyOf": [
                    {
                      "value": "[if(empty(field('Microsoft.Storage/storageAccounts/sasPolicy.sasExpirationPeriod')), 0, int(split(field('Microsoft.Storage/storageAccounts/sasPolicy.sasExpirationPeriod'), createArray(':', '.'))[1]))]",
                      "notEquals": 0
                    },
                    {
                      "value": "[if(empty(field('Microsoft.Storage/storageAccounts/sasPolicy.sasExpirationPeriod')), 0, int(split(field('Microsoft.Storage/storageAccounts/sasPolicy.sasExpirationPeriod'), createArray(':', '.'))[2]))]",
                      "notEquals": 0
                    },
                    {
                      "value": "[if(empty(field('Microsoft.Storage/storageAccounts/sasPolicy.sasExpirationPeriod')), 0, int(split(field('Microsoft.Storage/storageAccounts/sasPolicy.sasExpirationPeriod'), createArray(':', '.'))[3]))]",
                      "notEquals": 0
                    }
                  ]
                }
              ]
            },
            {
              "field": "Microsoft.Storage/storageAccounts/sasPolicy.expirationAction",
              "exists": "false"
            },
            {
              "field": "Microsoft.Storage/storageAccounts/sasPolicy.expirationAction",
              "notEquals": "Block"
            }
          ]
        }
      ]
    },
    "then": {
      "effect": "[parameters('effect')]"
    }
  }
```

- **Blocks:** Denies storage accounts whose SAS expiration policy allows tokens valid for more than 7 days, which limits how long a leaked token can move data out.
- **Breaks:** Existing storage accounts with longer SAS lifetimes are marked non-compliant but not changed. ([source](https://learn.microsoft.com/en-us/azure/governance/policy/concepts/effect-deny))
- **Test before applying:** As for every Azure Policy guardrail: [how to test before enforcing](/mechanisms/azure-policy/)
- **Mechanism:** [Azure Policy (built-in definitions)](/mechanisms/azure-policy/): Resources at the scope of the assignment (management group, subscription, resource group) and their children, except notScopes and exemptions
- **Taken from:** [open source set](https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-policies/policyDefinitions/Storage/EnforceStorageSasMaxExpiration7Days_Deny.json), MIT License, Azure/azure-policy repository, https://raw.githubusercontent.com/Azure/azure-policy/master/LICENSE

## What the source says

"This policy ensures that Shared Access Signature (SAS) tokens for storage accounts are configured with a maximum validity period of 7 days or less." (read 10 Nov 2026).

What it breaks is documented for every guardrail of this mechanism: see [Azure Policy](/mechanisms/azure-policy/).

## Related guardrails

- [Deny AWS RAM sharing with external accounts](/guardrails/aws-scp-deny-ram-external-sharing/): AWS, Service control policies (SCPs), data exfiltration
- [Block public sharing of EBS snapshots (declarative policy)](/guardrails/aws-declarative-snapshot-block-public-access/): AWS, Declarative policies, data exfiltration
- [Domain restricted sharing](/guardrails/gcp-orgpolicy-domain-restricted-sharing/): Google Cloud, Organization Policy Service (managed and legacy constraints), data exfiltration

## Related pages

- [Key vaults should have deletion protection enabled (Azure Azure Policy)](/guardrails/azure-policy-keyvault-purge-protection/)
- [Azure Key Vault should use the RBAC permission model (Azure Azure Policy)](/guardrails/azure-policy-keyvault-use-rbac/)
- [Configure key vaults to enable the firewall (Azure Azure Policy)](/guardrails/azure-policy-keyvault-firewall/)

## Sources

- Storage SAS tokens should adhere to 7 day maximum validity: https://raw.githubusercontent.com/Azure/azure-policy/master/built-in-policies/policyDefinitions/Storage/EnforceStorageSasMaxExpiration7Days_Deny.json (read 10 Nov 2026)
- What it breaks: https://learn.microsoft.com/en-us/azure/governance/policy/concepts/effect-deny (read 10 Nov 2026)
- How to test it first: https://learn.microsoft.com/en-us/azure/governance/policy/concepts/assignment-structure (read 10 Nov 2026)

Last reviewed 16 Nov 2026. Canonical: https://cloudgovernancetools.com/guardrails/azure-policy-storage-sas-7-days/
