azure - How to Create a Empty File using ADF Web API Activity in ADLS GEN2 - Stack Overflow

admin2025-04-18  2

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": ".done",
    "body": " ",
    "authentication": {
        "type": "MSI",
        "resource": "/"
    }
}

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

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

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

Share Improve this question asked Jan 29 at 14:52 SharmaSharma 4111 gold badge5 silver badges17 bronze badges 5
  • Can you check whether you it is generating any file after the error? – Rakesh Govindula Commented Jan 29 at 15:04
  • No there are no files generated – Sharma Commented Jan 29 at 15:11
  • Let me try from my end and I will update here. – Rakesh Govindula Commented Jan 29 at 15:13
  • ok sure Rakesh. – Sharma Commented Jan 29 at 16:31
  • I have posted the answer, please check it. – Rakesh Govindula Commented Jan 30 at 20:04
Add a comment  | 

1 Answer 1

Reset to default 3

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.

转载请注明原文地址:http://anycun.com/QandA/1744958917a90042.html