PARALLAX

azure_rm_storageaccount

Manage Azure storage accounts

Collection: azure.azcollection

Full Name: azure.azcollection.azure_rm_storageaccount

Synopsis

Manage Azure storage accounts

Parameters

NameTypeRequiredDefaultDescription
access_tierstringThe access tier for this storage account. Required when I(kind=BlobStorage).
account_typestringType of storage account. Required when creating a storage account.
C(Standard_ZRS) and C(Premium_LRS) accounts cannot be changed to other account types.
Other account types cannot be changed to C(Standard_ZRS) or C(Premium_LRS).
ad_userstringActive Directory username. Use when authenticating with an Active Directory user rather than service principal.
adfs_authority_urlstringAzure AD authority url. Use when authenticating with Username/password, and has your own ADFS authority.
allow_blob_public_accessboolAllows blob containers in account to be set for anonymous public access.
If set to false, no containers in this account will be able to allow anonymous public access.
If omitted, new account creation will default to null which is currently interpreted to True. Existing accounts will not be modified.
allow_cross_tenant_replicationboolAllow or disallow cross AAD tenant object replication.
allow_shared_key_accessboolIndicates whether the storage account permits requests to be authorized with the account access key via Shared Key.
If false, then all requests, including shared access signatures, must be authorized with Azure Active Directory (Azure AD).
The default value is null, which is equivalent to true.
api_profilestringlatestSelects an API profile to use when communicating with Azure services. Default value of C(latest) is appropriate for public clouds; future values will allow use with Azure Stack.
append_tagsbooltrueUse to control if tags field is canonical or just appends to existing tags.
When canonical, any tags not found in the tags parameter will be removed from the object’s metadata.
auth_modestringkeyThe mode in which to run the command. C(login) mode will directly use your login credentials for the authentication.
The legacy C(key) mode will attempt to query for an account key if no authentication parameters for the account are provided.
Can also be set via the environment variable C(AZURE_STORAGE_AUTH_MODE).
auth_sourcestringautoControls the source of the credentials to use for authentication.
Can also be set via the C(ANSIBLE_AZURE_AUTH_SOURCE) environment variable.
When set to C(auto) (the default) the precedence is module parameters -> C(env) -> C(credential_file) -> C(cli).
When set to C(env), the credentials will be read from the environment variables.
When set to C(credential_file), it will read the profile from C(~/.azure/credentials).
When set to C(cli), the credentials will be sources from the Azure CLI profile. C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID) can be used to identify the subscription ID if more than one is present otherwise the default az cli subscription is used.
When set to C(msi), the host machine must be an azure resource with an enabled MSI extension. C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID) can be used to identify the subscription ID if the resource is granted access to more than one subscription, otherwise the first subscription is chosen.
The C(msi) was added in Ansible 2.6.
blob_corslistSpecifies CORS rules for the Blob service.
You can include up to five CorsRule elements in the request.
If no blob_cors elements are included in the argument list, nothing about CORS will be changed.
If you want to delete all CORS rules and disable CORS for the Blob service, explicitly set I(blob_cors=[]).
cert_validation_modestringControls the certificate validation behavior for Azure endpoints. By default, all modules will validate the server certificate, but when an HTTPS proxy is in use, or against Azure Stack, it may be necessary to disable this behavior by passing C(ignore). Can also be set via credential file profile or the C(AZURE_CERT_VALIDATION) environment variable.
client_idstringAzure client ID. Use when authenticating with a Service Principal or Managed Identity (msi).
Can also be set via the C(AZURE_CLIENT_ID) environment variable.
cloud_environmentstringAzureCloudFor cloud environments other than the US public cloud, the environment name (as defined by Azure Python SDK, eg, C(AzureChinaCloud), C(AzureUSGovernment)), or a metadata discovery endpoint URL (required for Azure Stack). Can also be set via credential file profile or the C(AZURE_CLOUD_ENVIRONMENT) environment variable.
custom_domaindictUser domain assigned to the storage account.
Must be a dictionary with I(name) and I(use_sub_domain) keys where I(name) is the CNAME source.
Only one custom domain is supported per storage account at this time.
To clear the existing custom domain, use an empty string for the custom domain name property.
Can be added to an existing storage account. Will be ignored during storage account creation.
default_to_o_auth_authenticationboolA boolean flag which indicates whether the default authentication is OAuth or not.
The default interpretation is false for this property.
disable_instance_discoveryboolfalseDetermines whether or not instance discovery is performed when attempting to authenticate. Setting this to true will completely disable both instance discovery and authority validation. This functionality is intended for use in scenarios where the metadata endpoint cannot be reached such as in private clouds or Azure Stack. The process of instance discovery entails retrieving authority metadata from https://login.microsoft.com/ to validate the authority. By setting this to True, the validation of the authority is disabled. As a result, it is crucial to ensure that the configured authority host is valid and trustworthy.
Set via credential file profile or the C(AZURE_DISABLE_INSTANCE_DISCOVERY) environment variable.
enable_nfs_v3boolNFS 3.0 protocol.
encryptiondictThe encryption settings on the storage account.
force_delete_nonemptyboolfalseAttempt deletion if resource already exists and cannot be updated.
https_onlyboolAllows https traffic only to storage service when set to C(True).
If omitted, new account creation will default to True, while existing accounts will not be change.
identitydictIdentity for this resource.
immutable_storage_with_versioningdictThe property is immutable and can only be set to true at the account creation time.
When set to true, it enables object level immutability for all the containers in the account by default.
is_hns_enabledboolAccount HierarchicalNamespace enabled if sets to true.
When I(is_hns_enabled=True), I(kind) cannot be C(Storage).
kindstringStorageV2The kind of storage.
The C(FileStorage) and (BlockBlobStorage) only used when I(account_type=Premium_LRS) or I(account_type=Premium_ZRS).
C(Storage) (general-purpose v1) and C(BlobStorage) are legacy account kinds that Azure is retiring. Microsoft is disabling creation of new legacy blob storage accounts in September 2026 and will fully retire both kinds in October 2026 (any remaining accounts will be auto-migrated to C(StorageV2)). Use C(StorageV2) for all new accounts.
large_file_shares_statestringAllow large file shares if sets to Enabled.
locationstringValid Azure location. Defaults to location of the resource group.
log_modestringParent argument.
log_pathstringParent argument.
minimum_tls_versionstringThe minimum required version of Transport Layer Security (TLS) for requests to a storage account.
If omitted, new account creation will default to null which is currently interpreted to TLS1_0. Existing accounts will not be modified.
namestringyesName of the storage account to update or create.
network_aclsdictManages the Firewall and virtual networks settings of the storage account.
oidc_tokenstringDirect OpenID Connect (OIDC) token (JWT) used for workload identity authentication.
This token is exchanged with Azure AD using OIDC federated identity.
Useful in CI systems (for example GitHub Actions, Azure DevOps) where an OIDC token is provided directly by the platform.
Can also be set via the C(AZURE_FEDERATED_TOKEN) environment variable.
oidc_token_file_pathstringPath to a file containing an OpenID Connect (OIDC) token (JWT) used for workload identity authentication.
The file must contain only raw token.
This method is commonly used in platforms that materialize OIDC tokens as files
Can also be set via the C(AZURE_FEDERATED_TOKEN_FILE) environment variable.
passwordstringActive Directory user password. Use when authenticating with an Active Directory user rather than service principal.
profilestringSecurity profile found in ~/.azure/credentials file.
public_network_accessstringAllow or disallow public network access to Storage Account.
resource_groupstringyesName of the resource group to use.
secretstringAzure client secret. Use when authenticating with a Service Principal.
smb_oauth_enabledboolWhether managed identities can access Azure Files SMB shares using OAuth.
When unset, the value on Azure is left unchanged (the service default is C(false) for new accounts).
statestringpresentState of the storage account. Use C(present) to create or update a storage account and use C(absent) to delete an account.
C(failover) is used to failover the storage account to its secondary. This process can take up to a hour.
static_websitedictManage static website configuration for the storage account.
subscription_idstringYour Azure subscription Id.
tagsdictDictionary of string:string pairs to assign as metadata to the object.
Metadata tags on the object will be updated with any provided values.
To remove tags set append_tags option to false.
Currently, Azure DNS zones and Traffic Manager services also don’t allow the use of spaces in the tag.
Azure Front Door doesn’t support the use of
Azure Automation and Azure CDN only support 15 tags on resources.
tenantstringAzure tenant ID. Use when authenticating with a Service Principal.
thumbprintstringThe thumbprint of the private key specified in I(x509_certificate_path).
Use when authenticating with a Service Principal.
Required if I(x509_certificate_path) is defined.
x509_certificate_pathstringPath to the X509 certificate used to create the service principal in PEM format.
The certificate must be appended to the private key.
Use when authenticating with a Service Principal.

Example

yaml
- name: remove account, if it exists
  azure.azcollection.azure_rm_storageaccount:
    resource_group: myResourceGroup
    name: clh0002
    state: absent

- name: create an account
  azure.azcollection.azure_rm_storageaccount:
    resource_group: myResourceGroup
    name: clh0002
    type: Standard_RAGRS
    tags:
      testing: testing
      delete: on-exit

- name: Create an account with kind of FileStorage
  azure.azcollection.azure_rm_storageaccount:
    resource_group: myResourceGroup
    name: c1h0002
    type: Premium_LRS
    kind: FileStorage
    tags:
      testing: testing

- name: Create storage account with I(enable_nfs_v3=false)
  azure.azcollection.azure_rm_storageaccount:
    resource_group: myResourceGroup
    name: c1h0002
    account_type: Premium_LRS
    kind: FileStorage
    enable_nfs_v3: false
    static_website:
      enabled: true

- name: configure firewall and virtual networks
  azure.azcollection.azure_rm_storageaccount:
    resource_group: myResourceGroup
    name: clh0002
    type: Standard_RAGRS
    network_acls:
      bypass: AzureServices,Metrics
      default_action: Deny
      virtual_network_rules:
        - id: /subscriptions/mySubscriptionId/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet
          action: Allow
      ip_rules:
        - value: 1.2.3.4
          action: Allow
        - value: 123.234.123.0/24
          action: Allow

- name: create an account with blob CORS
  azure.azcollection.azure_rm_storageaccount:
    resource_group: myResourceGroup
    name: clh002
    type: Standard_RAGRS
    blob_cors:
      - allowed_origins:
          - http://www.example.com/
        allowed_methods:
          - GET
          - POST
        allowed_headers:
          - x-ms-meta-data*
          - x-ms-meta-target*
          - x-ms-meta-abc
        exposed_headers:
          - x-ms-meta-*
        max_age_in_seconds: 200

- name: Create new storage account with (key_source=Microsoft.Keyvault)
  azure.azcollection.azure_rm_storageaccount:
    resource_group: "{{ resource_group }}"
    name: "{{ storage_account_name }}"
    account_type: Standard_RAGRS
    kind: StorageV2
    identity:
      type: UserAssigned
      user_assigned_identity: "{{ managed_identity_ids[0] }}"
    encryption:
      services:
        blob:
          enabled: true
        file:
          enabled: true
      require_infrastructure_encryption: false
      key_source: Microsoft.Keyvault
      key_vault_properties:
        key_vault_uri: "https://vaultestfred001.vault.azure.net/"
        key_name: testkey
        key_version: 0bd2556671c64fc998095603878beb12
      encryption_identity:
        encryption_user_assigned_identity: "{{ managed_identity_ids[0] }}"

- name: Configure resource instance rules for Backup Vault and Synapse
  azure.azcollection.azure_rm_storageaccount:
    resource_group: myResourceGroup
    name: mystorageacct
    account_type: Standard_LRS
    kind: StorageV2
    public_network_access: Enabled
    network_acls:
      default_action: Deny
      bypass: AzureServices
      resource_access_rules:
        - resource_id: "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroup/providers/Microsoft.DataProtection/BackupVaults/myBackupVault"
          tenant_id: "myTenantId"
        - resource_id: "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroup/providers/Microsoft.Synapse/workspaces/mySynapseWorkspace"
          tenant_id: "myTenantId"

- name: Remove all resource instance rules
  azure.azcollection.azure_rm_storageaccount:
    resource_group: myResourceGroup
    name: mystorageacct
    network_acls:
      default_action: Deny
      bypass: AzureServices
      resource_access_rules: []

- name: Create a StorageV2 account with SMB OAuth enabled for Managed Identity access
  azure.azcollection.azure_rm_storageaccount:
    resource_group: myResourceGroup
    name: mystorageacct
    account_type: Standard_LRS
    kind: StorageV2
    smb_oauth_enabled: true
Search
    ↑ ↓ move↵ openesc close