Issue with SAS URL Format for Output Container in Azure Document Redaction API

Swapnil Singh 0 Reputation points
2025-07-31T08:29:48.62+00:00

I'm encountering a 403 AuthorizationFailure error when using Azure's Document Redaction API, specifically when trying to save the redacted output to a Blob Storage container using a SAS URL. While the SAS URL for the source blob works as expected, the output container SAS URL results in an authorization error, even though it was generated at the container level with write and list (sp=wl) permissions. I also attempted to add restype=container to the URL but still faced the same issue. I’m unsure if the problem is due to incorrect SAS token permissions, an improperly structured URL, or a missing parameter. I need clarification on the correct SAS URL format and permissions required to enable successful writing of redacted documents to a container.

I am trying to use the Azure Language Service API to perform PII redaction on a document stored in Azure Blob Storage. Below is the request payload I’m using:

{
  "displayName": "Document PII Redaction example",
  "analysisInput": {
    "documents": [
      {
        "language": "en-US",
        "id": "Output-1",
        "source": {
          "location": "<source-blob-SAS-URL>"
        },
        "target": {
          "location": "<output-container-SAS-URL>"
        }
      }
    ]
  },
  "tasks": [
    {
      "kind": "PiiEntityRecognition",
      "taskName": "Redact PII Task 1",
      "parameters": {
        "redactionPolicy": {
          "policyKind": "entityMask"
        },
        "piiCategories": ["Person", "Organization"],
        "excludeExtractionData": false
      }
    }
  ]
}

I’m calling this endpoint: POST https://<your-language-resource>.cognitiveservices.azure.com/language/analyze-documents/jobs?api-version=2024-11-15-preview

Issue:

The source blob SAS URL works correctly when tested in a browser.

However, the redaction job fails due to a 403 error when writing to the output container.

  • Here's the error message I receive in the job status response:
    "Unauthorized to access the blob. This request is not authorized to perform this operation." Status: 403 (AuthorizationFailure) ErrorCode: AuthorizationFailure Example Output SAS URL : https://<your-storage-account>.blob.core.windows.net/targetcontainer?sp=wl&st=2025-07-31T07:05:37Z&se=2025-08-02T15:20:37Z&sip=0.0.0.0-255.255.255.255&sv=2024-11-04&sr=c&sig=<signature>
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
{count} votes

1 answer

Sort by: Most helpful
  1. Nandamuri Pranay Teja 4,445 Reputation points Microsoft External Staff Moderator
    2025-08-05T14:06:52.08+00:00

    Hello Swapnil Singh

    Thank you for the response!

    Please confirm How are you generating the SAS token? (Portal, CLI, PowerShell, SDK) What exact error message do you get with curl? (include the full response) Can you share the complete SAS URL structure? (with sensitive parts redacted like: https://account.blob.core.windows.net/container?sp=...&sig=REDACTED) Are you using a standard storage account or premium/special configuration?

    However, in the meantime Let's test your SAS token step by step:

    List container contents

    curl -X GET "https://<account>.blob.core.windows.nt/<container>?restype=container&comp=list&<your-sas-token>" 
    

    Upload a test blob

    curl -X PUT "https://<account>.blob.core.windows.net/<container>/test.txt?<your-sas-token>" \
      -H "x-ms-blob-type: BlockBlob" \
      -H "Content-Type: text/plain" \
      -d "test content"
    

    Check for these common problems:

    Clock Skew Issues Ensure your system time is accurate. Add buffer time

    # Start time 15 minutes ago, expiry well in future
    --start-time "2025-08-05T06:00:00Z" \
    --expiry "2025-08-10T00:00:00Z"
    

    Make sure you're using the correct storage account key:

    # Get the correct key
    az storage account keys list --account-name <account> --resource-group <rg>
    

    Your SAS URL should look like this:

    https://<account>.blob.core.windows.net/<container>?sp=racwdli&st=2025-08-05T06%3A00%3A00Z&se=2025-08-10T00%3A00%3A00Z&sv=2024-11-04&sr=c&sig=<signature>
    

    Do let me know if you have any questions!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.