An Azure service that offers file shares in the cloud.
Hello Dmitry,
Thank for your question!
I understand that you are experiencing a 403 error when attempting to create a directory, although other operations are functioning correctly. Considering that the date in your x-ms-date header (Sun, 04 May 2025 22:11:02 GMT) is prior to the current time in you location (Day, Month-Date, year, time, AM-PM), this should not be the main reason for the 403 "AuthenticationFailed" error in Azure Storage.
The string-to-sign seems to have an issue with the CanonicalizedResource part. Specifically, the query parameter restype=directory is appended as a separate line, which is incorrect. According to the Azure Shared Key authorization documentation, query parameters should not be included in the CanonicalizedResource unless they are part of a specific set of signed query parameters (e.g., comp, snapshot), and restype is not one of them.
The string-to-sign for Shared Key authorization should follow this format for Azure File Storage:
StringToSign = VERB + "\n" +
Content-Encoding + "\n" +
Content-Language + "\n" +
Content-Length + "\n" +
Content-MD5 + "\n" +
Content-Type + "\n" +
Date + "\n" +
If-Modified-Since + "\n" +
If-Match + "\n" +
If-None-Match + "\n" +
If-Unmodified-Since + "\n" +
Range + "\n" +
CanonicalizedHeaders +
CanonicalizedResource
Issues in Your String-to-Sign:
The line /skillrx/skillrx-staging-env/test_created\nrestype:directory is incorrect. The restype=directory query parameter should not be included in the CanonicalizedResource. The CanonicalizedResource should only include the account name and the resource path, like:
/skillrx/skillrx-staging-env/test_created
You have included x-ms-date and x-ms-version, which is correct, but ensure they are sorted alphabetically and formatted properly. Your format looks correct here:
x-ms-date:Sun, 04 May 2025 22:11:02 GMT\nx-ms-version:2025-01-05
The empty fields (e.g., Content-Length, Content-Type) are correctly represented as empty strings (\n), which is fine for a directory creation request since no body is sent.
the corrected string-to-sign should be:
PUT\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:Sun, 04 May 2025 22:11:02 GMT\nx-ms-version:2025-01-05\n/skillrx/skillrx-staging-env/test_created
- Verify the storage account key is correct and corresponds to the skillrx account.
- Ensure the account has permissions to create directories in the skillrx-staging-env file share.
- The HMAC-SHA256 signature must be computed correctly using the storage account key.
- Ensure the storage account key is correct and has permissions to create directories.
- The x-ms-date header must be within 15 minutes of the server's time.
Hope the above answer helps! Please let us know do you have any further queries.
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.