azureazure-functionsazure-deploymentazure-bicep

How to make an azure function that deploys my bicep script from Azure Storage Account


I'm trying to deploy my bicep script with module that are located in my Azure storage account. And this doesn't work at all. I'm using Powershel, should I use something else?

New-AzResourceGroupDeployment -ResourceGroupName test01
  -TemplateFile "https://xxxyyyzzzz.blob.core.windows.net/my-bicepscript/main.bicep"
  -TemplateParameterObject $params

Solution

  • How to make an azure function that deploys my bicep script from Azure Storage Account.

    You cannot deploy the Bicep file from a storage account as it's not supported, but you can deploy a JSON file from a storage account using -TemplateUri. Refer to the MS Doc for more details

    Alternatively, you can deploy a Bicep file by downloading it locally and use the same file for deployment in a single execution using the script below.

        $storageAccount = Get-AzStorageAccount -ResourceGroupName "venkatrg" -Name "demorgtest"
        $ctx = $storageAccount.Context
        Get-AzStorageBlobContent -Container "bicep" -Blob "Resourcegroup.bicep" -Context $ctx -Destination "<Local_Path>"
        New-AzResourceGroupDeployment -ResourceGroupName "venkatrg" -TemplateFile "<Local_Path>/Resourcegroup.bicep"
        
     New-AzResourceGroupDeployment -ResourceGroupName "venkatrg" -TemplateFile .\Resourcegroup.bicep
    

    Output:

    enter image description here

    After executing the above script, the Bicep deployment has been completed and created Vnet with 2 subnets.

    I have used the VNet module for testing.

    enter image description here