下面是我们使用的python代码
将访问这些文件,然后将其上载到存储容器
def az_upload_blob(tenantID, container_name, file_name, data):
try:
logger.debug("Info::Acessing uBlob.")
AZURE_STORAGE_CONNECTION_STRING = az_kv_getsecret(Con.KV_RINGR_URI, Con.KV_SEC_CONN_STRING)
blob_service_client = BlobServiceClient.from_connection_string(AZURE_STORAGE_CONNECTION_STRING)
blob_client = blob_service_client.get_blob_client(container=container_name, blob=file_name)
blob_client.upload_blob(data)
logger.debug("Info:: Blob uploaded")
except Exception as ex:
logger.error(f"uBlob:: {ex}")
raise Exception(f"AZ-uBlob-Exception: {ex}")
错误消息:
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:23025256-801e-0047-3150-3b8ba5000000
Time:2021-04-27T10:34:18.1487489Z
ErrorCode:AuthenticationFailed
Error:None
AuthenticationErrorDetail:The MAC signature found in the HTTP request 'xyyz' is not the same as any computed signature. Server used following string to sign: 'PUT
636
application/octet-stream
*
x-ms-blob-type:BlockBlob
x-ms-client-request-id:1ebf24c8-a744-11eb-be9d-000d3a99de90
x-ms-date:Tue, 27 Apr 2021 10:34:18 GMT
x-ms-encryption-algorithm:AES256
x-ms-version:2020-06-12
请帮忙查找丢失的项目。谢谢大家!
更新:
我使用下面的代码,它工作得很好:
如果我运行python脚本,我首先运行'az login',然后运行:
如果我在azure函数中使用它们,我只需将凭据更改为“ManagedEntityCredential”,并将函数应用程序的访问策略添加到azure密钥库(在我这方面,我授予完全访问权限)
原始答案:
你能给我看看az_kv_getsecre吗?事实上,我们总是从azure blob存储中复制连接字符串
格式如下:
DefaultEndpointsProtocol=https;AccountName=youraccountname;AccountKey=xxxxxx;EndpointSuffix=core.windows.net
相关问题 更多 >
编程相关推荐