I need to create a new empty file in ALDS GEN2 using WEB API activity in ADF.
Below is the request i am using to create a file
{
"method": "PUT",
"headers": {
"x-ms-version": "2021-06-08",
"x-ms-blob-type": "BlockBlob",
"x-ms-date": "Wed, 29 Jan 2025 14:37:47 GMT",
"Content-Length": "0",
"Authorization": "SharedKey {storage_account_name}:{staorage_account_access_key}"
},
"url": "https://sample.dfs.core.windows.net/test-data/csv/archive/test.done",
"body": " ",
"authentication": {
"type": "MSI",
"resource": "https://storage.azure.com/"
}
}
But i am getting below error and according to the documentation i have passed all the required values in header
{"error":{"code":"MissingRequiredHeader","message":"An HTTP header that's mandatory for this request is not specified.\nRequestId:swjdbjw4-ewj-sjcb-315b-cdsccdsc\nTime:2025-01-29T14:37:49.3616136Z"}}
I have referred following documentation https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob?tabs=microsoft-entra-id
Can anyone help me to resolve the above issue and create a new empty file.
Authentication is System Assigned Managed Identity, please find the below screenshot
As you are already using a System-assigned managed identity as authentication, there is no need to use any Bearer token or Shared access key for the authorization. This might be the reason for your error.
You can follow the below step by step process to achieve your requirement.
Use the below configurations in the ADF web activity.
URL - https://<storage_account_name>.dfs.core.windows.net/<container_name><folder_and_filepath>?resource=file&x-ms-version=2018-11-09
Method - PUT
Body - {}
Authentication- System-assigned managed identity
Resource - https://storage.azure.com/
Headers:
Content-type - application/octet-stream
x-ms-date - @{formatDateTime(utcnow(),'r')}
You need to ensure that you have assigned Storage Blob Data contributor role to your System-assigned managed identity in ADLS Gen2. You can check the access of the managed identity in the storage account like below.
Now, debug the pipeline and the empty file in the given folder will be created in the ADLS gen2 container as shown below.