Azure blob container shared access signature expiring Azure blob container shared access signature expiring azure azure

Azure blob container shared access signature expiring


One thing you could do is create your access policy without expiry date. You specify the expiry date when you're creating the signed URL.

So your code would look something like:

        SharedAccessPolicy sharedAccessPolicy = new SharedAccessPolicy();        sharedAccessPolicy.Permissions = SharedAccessPermissions.Read;        sharedAccessPolicy.SharedAccessStartTime = DateTime.UtcNow;        //sharedAccessPolicy.SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(1); No need to define expiry time here.        BlobContainerPermissions blobContainerPermissions = new BlobContainerPermissions();        blobContainerPermissions.SharedAccessPolicies.Add("default", sharedAccessPolicy);        container.SetPermissions(blobContainerPermissions);        Console.WriteLine("Press any key to continue....");        Console.ReadLine();        CloudBlob blob = container.GetBlobReference(path);        string sas = blob.GetSharedAccessSignature(new SharedAccessPolicy()        {            SharedAccessExpiryTime = DateTime.UtcNow.AddDays(7),//add expiry date only when you're creating the signed URL        }            , "default");        Console.WriteLine(blob.Uri.AbsoluteUri + sas);        Process.Start(new ProcessStartInfo(blob.Uri.AbsoluteUri + sas));        Console.WriteLine("Press any key to continue....");        Console.ReadLine();

Will this work for you? Obviously you would need to regenerate the URL after 7 days but you don't have to make any changes to your access policy.

Hope this helps.


With a 1 minute expiration you might be hitting clock skew effects between the SAS generation box and Windows Azure Storage. You should use a longer interval. I did a post going into the gory depths of shared access signatures, that you might find helpful.


You may be hitting the maximum on container level access policies.

A stored access policy includes a name up to 64 characters long that is unique within the container. This name appears in the signedidentifier field on Shared Access Signatures that link to a stored access policy. A container can include up to 5 stored access policies. Each policy can be used by any number of Shared Access Signatures.

Using a Stored Access Policy