Skip to content

Instantly share code, notes, and snippets.

@igoravl
Last active May 4, 2023 02:15
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 igoravl/0921e9be7e1b85e46e3be192768fbcc5 to your computer and use it in GitHub Desktop.
Save igoravl/0921e9be7e1b85e46e3be192768fbcc5 to your computer and use it in GitHub Desktop.
Create a storage account for subsequent Terraform usage
@description('Specifies the name of the Azure Storage account.')
param storageAccountName string
@description('Specifies the name of the blob container.')
param containerName string = 'tfstate'
@description('Specifies the location in which the Azure Storage resources should be deployed.')
param location string = resourceGroup().location
@description('Specifies the SKU for the Storage Account.')
param sku string = 'Standard_LRS'
resource sa 'Microsoft.Storage/storageAccounts@2021-06-01' = {
name: storageAccountName
location: location
sku: {
name: sku
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
}
}
resource blobService 'Microsoft.Storage/storageAccounts/blobServices@2021-06-01' = {
parent: sa
name: 'default'
}
resource container 'Microsoft.Storage/storageAccounts/blobServices/containers@2021-06-01' = {
parent: blobService
name: containerName
}
// Output connection string
var blobStorageConnectionString = 'DefaultEndpointsProtocol=https;AccountName=${sa.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${sa.listKeys().keys[0].value}'
output connectionString string = blobStorageConnectionString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment