how to upload files from AWS lambda to Azure Storage ADLS Gen 2

Amit Mehta 30 Reputation points
2025-03-20T18:54:58.5633333+00:00

I have to upload files coming in AWS S3 bucket to azure BLOB Storage in specific folder. So I have written a lambda function in python that gets invoked when a file is put in the S3 and the lambda code tries to upload to azure blob. But currently is fails with error -

Content: <?xml version="1.0" encoding="utf-8"?><Error><Code>AuthorizationFailure</Code><Message>This request is not authorized to perform this operation.

What do I need to do on the Azure BLOB container side to allow this lambda upload to go through?

Here is the python code that I am using to upload:

		response = s3.get_object(Bucket=bucket, Key=key)
        #read object content
        content = response['Body'].read().decode('utf-8')
        #print(f"Content: {content}")
        #connect to Azure Blob Storage
        connection_string = os.environ['AZURE_STORAGE_CONNECTION_STRING']
        container_name = os.environ['container_name']
        folder_path = os.environ['folder_path']  # Specify the folder path within the container
        blob_service_client = BlobServiceClient.from_connection_string(connection_string)
        container_client = blob_service_client.get_container_client(container_name)
        file_name = os.path.basename(key)
        blob_name = folder_path + file_name
        print("BLOB NAME: " + blob_name)
        blob_client = container_client.get_blob_client(blob_name)
        #upload file to Azure Blob Storage
        blob_client.upload_blob(content, overwrite=True)
Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,462 questions
{count} votes

Accepted answer
  1. Keshavulu Dasari 4,480 Reputation points Microsoft External Staff
    2025-03-21T19:20:42.4266667+00:00

    @ Amit Mehta,

    Using Private Endpoint connections can be a good option for securely connecting your AWS Lambda function and .Net Core application to Azure Blob Storage.

    For Lambda Private Endpoints allow you to connect to Azure services over a private link, which means the traffic between your AWS Lambda function and Azure Blob Storage will be routed through a secure, private network.

    You will need to set up a Site-to-Site VPN or an AWS Direct Connect to establish a private network connection between AWS and Azure.

    Ensure that your AWS Lambda function is configured to use a VPC endpoint that can route traffic to the Azure Private Endpoint.

    Update your Lambda function's network settings to use the private IP address of the Azure Private Endpoint.

    For .Net Core Application, using a Private Endpoint for your .Net Core application running on an on-premises server can enhance security by ensuring that data transfers to Azure Blob Storage occur over a private network.

    You will need to set up a VPN connection from your on-premises network to Azure to access the Private Endpoint.

    Configure your on-premises network to route traffic to the Azure Private Endpoint.

    Update your .Net Core application to use the private IP address of the Azure Private Endpoint for connecting to Azure Blob Storage.Using Private Endpoint connections can be a good option for securely connecting your AWS Lambda function and .Net Core application to Azure Blob Storage.

    Benefits, Traffic is routed through a private network, reducing exposure to the public internet, Private connections can offer more consistent and potentially faster data transfer rates.

    For more information:

    https://learn.microsoft.com/en-us/azure/vpn-gateway/vpn-gateway-howto-aws-bgp

    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
    User's image

    If you have any other questions or are still running into more issues, let me know in the "comments" and I would be glad to assist you

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.