azure-filesazure-file-share

Use Control plane API to Create Share at Azure File with share key


I used the control plane API to create a share at Azure File. API: https://learn.microsoft.com/en-us/rest/api/storagerp/file-shares/create?view=rest-storagerp-2023-01-01&tabs=HTTP

The HTTP request:

PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/sharename?api-version=2023-01-01 HTTP/1.1
Host: management.azure.com
Authorization: SharedKey ***:***
Accept-Encoding: gzip, deflate
Connection: close
Content-Length: 17
x-ms-date: Thu, 18 Apr 2024 09:26:55 GMT
x-ms-version: 2023-01-01

I got an error : WWW-Authenticate: Bearer authorization_uri="https://login.windows.net/***", error="invalid_token", error_description="The authentication scheme of SharedKey is not supported."

Does the control API only support OAuth authentication?


Solution

  • Does the Control API only support OAuth authentication?

    According to this MS-Document:

    Yes, the Control API supports only OAuth2 authentication (Bearer token).

    API to Create Share at Azure File with share key

    You can use the below request to create a file share with a shared key.

    Request:

    PUT https://venkat123.file.core.windows.net/myshare?restype=share 
    Request Headers:
    x-ms-version: 2023-11-03 
    x-ms-date: Thu, 18 Apr 2024 10:24:55 GMT 
    Authorization: SharedKey <Your storage account name>:xxxxxMesKNh0xxxxJdjidOQ=
    

    Output: enter image description here

    Portal: enter image description here

    Reference: Create Share (FileREST API) - Azure Files | Microsoft Learn