skip to Main Content

I am trying to upload a file from my local system to adls. Below is the code to upload:

import os, uuid, sys
from azure.storage.filedatalake import DataLakeServiceClient
from azure.core._match_conditions import MatchConditions
from azure.storage.filedatalake._models import ContentSettings
from azure.identity import ClientSecretCredential

client_secret = <client_secret>
client_id = <client_id>
tenant_id = <tenant_id>
file_system = "fs-adls"
storage_account_name = "sgprod"
directory = "e2e"
file_name = "abc.py"

credential = ClientSecretCredential(tenant_id, client_id, client_secret)
service_client = DataLakeServiceClient(account_url="{}://{}.dfs.core.windows.net".format("https", storage_account_name), credential=credential)
file_system_client = service_client.get_file_system_client(file_system=file_system)
dest_directory_client = file_system_client.get_directory_client(directory)
f = open("run/abc.py",'r')
dest_file_client = dest_directory_client.create_file(file_name)
file_contents = f.read()
dest_file_client.upload_data(file_contents, overwrite=True)
f.close()

When I tried to run the above code in my local conda environment, I am getting the below error:

azure.core.exceptions.HttpResponseError: (AuthorizationFailure) This request is not authorized to perform this operation.
RequestId:699c1c01-901f-002a-1a5b-d9553a000000
Time:2022-10-06T08:16:24.7267071Z
Code: AuthorizationFailure
Message: This request is not authorized to perform this operation.
RequestId:699c1c01-901f-002a-1a5b-d9553a000000
Time:2022-10-06T08:16:24.7267071Z

I think the issue is with the IP address, the IP address of my local system needs to be whitelisted first (i.e it should be added to Azure Firewall). Is it the network IP or client IP that needs to be added to Azure Firewall and where can I find it?

2

Answers


  1. Chosen as BEST ANSWER

    Just google "what is my ip?" and it will show you which ip to be whitelisted. Just add that IP to your Azure Firewall for ADLS


  2. Use curl -4 ifconfig.co to get the local IP address. This works from Windows PowerShell, Linux (i.E. bash) and macOS.

    Since Azure requires the IPv4 address, the -4 parameter should be omitted in case your Internet Provider has assigned an IPv6 address.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search