Last active
January 21, 2024 18:44
-
-
Save amalgjose/561fc29e14ab5f87f881e40ea95983ca to your computer and use it in GitHub Desktop.
Python program to enable or disable the public access of an Azure Storage Account
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from azure.identity import ClientSecretCredential | |
from azure.mgmt.storage import StorageManagementClient | |
from azure.mgmt.storage.models import StorageAccountUpdateParameters | |
# Enter the subscription id, resource group name and storage account name | |
subscription_id = "xxxxxxxx" | |
resource_group_name="xxxxx" | |
storage_account_name="xxxx" | |
# Update the service principle credentials below. | |
credentials = ClientSecretCredential( | |
tenant_id="xxxxxx", | |
client_id="xxxxx", | |
client_secret="xxxxx" | |
) | |
storage_client = StorageManagementClient(credentials, subscription_id) | |
#Enable or disable public access (True/False) using the allow_blob_public_access parameter | |
az_property01 = StorageAccountUpdateParameters(allow_blob_public_access=False) | |
#Update the storage account with the new settings | |
storage_client.storage_accounts.update(resource_group_name, storage_account_name, az_property01) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment