Preparing Visual Studio Code for IaC (Azure) + Deploying a Storage Account using IaC
This article has not been completed yet. However, it may already contain helpful Information and therefore it has been published at this stage.
Prerequisites:
Extensions:
Installing Azure CLI:
$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi
Install the Azure Az PowerShell module:
Install-Module -Name Az -Scope CurrentUser -Force
https://it-infrastructure.solutions/how-to-connect-to-azure/
Create a Template + Parameterfile:
Strg + Space = Autovervollständigung
.......
azuredeploy.json:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"type": "string",
"metadata": {
"description": "Storage Account Name"
},
"minLength":3,
"maxLength":24
}
},
"functions": [],
"variables": {},
"resources": [{
"name": "[parameters('storageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-04-01",
"tags": {
"displayName": "storageaccount1"
},
"location": "[resourceGroup().location]",
"kind": "StorageV2",
"sku": {
"name": "Premium_LRS",
"tier": "Premium"
}
}],
"outputs": {}
}
azuredeploy.parameters.json:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"value": "apenitest1"
}
}
}
Connect-AzAccount
New-AzResourceGroup -Name test -Location westeurope
New-AzResourceGroupDeployment -ResourceGroupName test -TemplateFile .\azuredeploy.json -TemplateParameterFile .\azuredeploy.parameters.json
Source: