Hii DZIANIS DEV
Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.
In the Azure Portal, after finishing a deployment, you can download the ARM template by navigating to the "Deployments" section of your resource group, selecting the specific deployment, and then clicking on the "Overview" tab where you'll find the option to download the template.
You can manually convert an ARM template into a PowerShell script by using Azure PowerShell commands. This involves creating a script with commands such as "New-AzResourceGroupDeployment" to set up the resources defined in the ARM template.
Example of Converting an ARM Template to a PowerShell Script:-
{
"$schema": "https://schema.management.azure.com/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-04-01",
"name": "mystorageaccount",
"location": "West US",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2",
"properties": {}
}
]
}
PowerShell Script Example:-
Define parameters:-
$resourceGroupName = "myResourceGroup"
$location = "West US"
$storageAccountName = "mystorageaccount"
Deploy the storage account:-
New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName `
-TemplateFile "path_to_your_template.json" `
-storageAccountName $storageAccountName `
-Location $location
Azure CLI Alternative:-
If you’re open to using Azure CLI instead of PowerShell, you can deploy ARM templates with the AZ deployment group create command. This command is similar to its PowerShell counterpart but follows Azure CLI syntax.
Azure CLI Example:-
az group create --name myResourceGroup --location "West US"
az deployment group create --resource-group myResourceGroup --template-file path_to_your_template.json.
For reference, please review this documentation:- https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/quickstart-create-templates-use-visual-studio-code?tabs=CLI
Manage resources - Azure PowerShell - Azure Resource Manager | Microsoft Learn
If you have any further queries, do let us know.
If the answer is helpful, please click "Accept Answer" and "Upvote it".