You can't with this package, you need to use the ASM (Azure Service Management) package called azure-servicemanagement-legacy
: https://pypi.org/project/azure-servicemanagement-legacy/
See this unittest from this testfile: https://github.com/Azure/azure-sdk-for-python/blob/master/azure-servicemanagement-legacy/tests/test_legacy_mgmt_storage.py
def test_get_storage_account_keys(self):
# Arrange
self._create_storage_account(self.storage_account_name)
# Act
result = self.sms.get_storage_account_keys(self.storage_account_name)
# Assert
self.assertIsNotNone(result)
self.assertIsNotNone(result.url)
self.assertIsNotNone(result.service_name)
self.assertIsNotNone(result.storage_service_keys.primary)
self.assertIsNotNone(result.storage_service_keys.secondary)
self.assertIsNone(result.storage_service_properties)
Edit: You might want to try a ARM resource call using azure-mgmt-resource
(see https://stackoverflow.com/a/45814624/4074838 for details) to this URL: https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ClassicStorage/storageAccounts/{accountName}/listKeys?api-version=2015-06-01
You can create a ResourceManagementClient client client
, and call client.resources.get_by_id(subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ClassicStorage/storageAccounts/{accountName}/listKeys, '2015-06-01')
As described in the answer I mention however, there is no guarantee this call will continue to work in the future (if it's even still working now)
Ref: https://docs.microsoft.com/en-us/python/api/azure.mgmt.resource.resources.v2017_05_10.operations.resourcesoperations?view=azure-python#get-by-id