azurepowershellvirtual-machineazure-storagerunbook

Cannot download template file from Azure Storage in PowerShell Runbook


I want to deploy a Data Science VM automatically in a powershell runbook. To do so, I use the New-AzResourceGroupDeployment command and specify the parameter files in the -ParameterUri and -TemplateParameterUri. Unfortunately, powershell cannot download these files to use them. The Error Message is:

New-AzResourceGroupDeployment : 12:25:28 PM - Error: Code=InvalidContentLink; Message=Unable to download deployment content from 'https://[SAName].blob.core.windows.net/automation/WindowsVirtualMachine.json'. The tracking Id is '56714bef-f653-42bb-80e2-8d0842e2d94e'. Please see https://aka.ms/arm-deploy for usage details.

Part of my script: (The Deployment and ResourceGroupName are provided as well)

$TemplateUri = "https://[SAName].blob.core.windows.net/automation/WindowsVirtualMachine.json"
$TemplateParameterUri = "https://[SAName].blob.core.windows.net/automation/WindowsVirtualMachine.parameters.json"
New-AzResourceGroupDeployment -Name $ResourceGroupDeploymentName `
    -ResourceGroupName $ResourceGroupName `
    -TemplateUri $TemplateUri `
    -TemplateParameterUri $TemplateParameterUri `
    -Force

I just thougt that I have to give something like the Storage Account Context or something else to authorize powershell to access the files, isn't it? Perhaps there is some easier ways to reach my goal?

Thanks in Advance!


Solution

  • As per Mantri said, you should set the blob container to public, or provide a Shared Access Signature URL.

    Method 1.Change the blob container to public: nav into the container, then click "Change access level" -> select "Container(anonymous read xxxxx)"

    enter image description here

    Method 2.Provide a Shared Access Signature URL for the blob:

    enter image description here

    enter image description here