Skip to content

Instantly share code, notes, and snippets.

@amalgjose
Last active January 21, 2024 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amalgjose/561fc29e14ab5f87f881e40ea95983ca to your computer and use it in GitHub Desktop.
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
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