我正在尝试从本地系统上传一个文件到adls。下面是上传的代码:
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()
当我尝试在本地conda环境中运行上面的代码时,我得到了下面的错误:
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
我认为问题出在IP地址上,我的本地系统的IP地址需要首先加入白名单(即应该添加到Azure防火墙)。需要添加到Azure防火墙的是网络IP还是客户端IP,在哪里可以找到它?
2条答案
按热度按时间ekqde3dh1#
只需谷歌“我的IP是什么?”,它会显示要列入白名单的IP。只需将该IP添加到Azure Firewall for ADLS
toiithl62#
使用
curl -4 ifconfig.co
获取本地IP地址。此操作适用于Windows PowerShell、Linux(即bash)和macOS。由于Azure需要IPv4地址,因此如果Internet提供商已分配IPv6地址,则应省略
-4
参数。