skip to Main Content

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

2

Answers


  1. 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

    Login or Signup to reply.
  2. Case1:

    PS C:Userswenbo> New-AzResourceGroupDeployment -ResourceGroupName "wb-common-test-for-delete-rg" -TemplateUri "https://wbxxxxx.blob.core.windows.net/publictest/main.bicep"
    

    result:

    New-AzResourceGroupDeployment: Cannot retrieve the dynamic parameters for the cmdlet. The -TemplateUri parameter is not supported with .bicep files. Please download the file and pass it using -TemplateFile.
    

    Case2:

    PS C:Userswenbo> New-AzResourceGroupDeployment -ResourceGroupName "wb-common-test-for-delete-rg" -TemplateUri "https://wbxxxxx.blob.core.windows.net/publictest/main.json"
    

    result:

    DeploymentName          : main
    ResourceGroupName       : wb-common-test-for-delete-rg
    ProvisioningState       : Succeeded
    Timestamp               : 7/23/2024 2:20:07 AM
    Mode                    : Incremental
    TemplateLink            :
    ...                  
    

    Summarization:

    Whether using bicep file in local or json file in remote. Bicep in remote uri is not supported.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search