Jam*_*iro 1 python azure azure-storage
假设您具有管理员访问权限,并且刚刚在 Python 脚本中以编程方式创建了一个存储帐户。
然后,如何从 Python 中新创建的存储帐户中检索连接字符串?例如,如果您想在同一脚本中创建存储队列?
如果使用azure-mgmt-storage创建存储帐户,则可以按照本文获取连接字符串。
以下是上面示例中用于获取连接字符串的代码片段:
# 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}")
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1916 次 |
最近记录: |