【发布时间】:2021-04-11 18:40:16
【问题描述】:
假设您具有管理员访问权限,并且您刚刚在 Python 脚本中以编程方式创建了一个存储帐户。
然后如何从 Python 中新创建的存储帐户中检索连接字符串?例如,如果您想在同一个脚本中创建存储队列?
【问题讨论】:
标签: python azure azure-storage
假设您具有管理员访问权限,并且您刚刚在 Python 脚本中以编程方式创建了一个存储帐户。
然后如何从 Python 中新创建的存储帐户中检索连接字符串?例如,如果您想在同一个脚本中创建存储队列?
【问题讨论】:
标签: python azure azure-storage
如果您使用azure-mgmt-storage 创建存储帐户,则可以关注this article 获取连接字符串。
这是上面示例中用于获取连接字符串的代码 sn-p:
# Step 3: Retrieve the account's primary access key and generate a connection string.
keys = storage_client.storage_accounts.list_keys(RESOURCE_GROUP_NAME, STORAGE_ACCOUNT_NAME)
print(f"Primary key for storage account: {keys.keys[0].value}")
conn_string = f"DefaultEndpointsProtocol=https;EndpointSuffix=core.windows.net;AccountName={STORAGE_ACCOUNT_NAME};AccountKey={keys.keys[0].value}"
print(f"Connection string: {conn_string}")
【讨论】: