azure-devopsazure-resource-managerazure-pipelines-release-pipelinesas-token

InvalidContentLink ARM template deployment


I get the InvalidContentLink: Unable to download deployment content from error when pointing to URI (LinkedTemplatesBaseUrl) of my deployment json file.

Steps Im taking-

1. Azure CLi task to generate SAS token

# Set expiry time in UTC, formatted correctly for SAS
$expiryTime = (Get-Date).ToUniversalTime().AddMinutes(30).ToString("yyyy-MM-ddTHH:mmZ")

# Generate the SAS token using Azure CLI
$SasToken = az storage container generate-sas --account-name mystoragaccount `
    --name arm `
    --permissions r `
    --expiry $expiryTime `
    --auth-mode login `
    --as-user `
    --output tsv 

# Ensure there is no unintended whitespace or newline in the SAS token
$SasToken = $SasToken.Trim()

# Output SAS token for logging
Write-Host "Generated SAS Token: $SasToken"

# Set variable in Azure DevOps pipeline (marking it as secret)
Write-Host "##vso[task.setvariable variable=SasToken;isOutput=true;issecret=true]$SasToken"

Im referenicng this as GenerateSasToken

2. ARM tempalte deployment

steps:
- task: AzureResourceManagerTemplateDeployment@3
  displayName: 'Azure Deployment: AzResources '
  inputs:
    azureResourceManagerConnection: 'AZURE-Conn'
    subscriptionId: 'xxxxx-xx-xxx-xxxx-xxxxx'
    resourceGroupName: myrg
    location: 'West Europe'
    csmFile: '$(drop)/AzureServices/Master/**Master_Deployment_Template**.json'
    csmParametersFile: '$(drop)/AzureServices/Master/Master_Deployment_Template_Parameters.json'
    overrideParameters: '-LinkedTemplatesBaseUrl "$(blob.StorageContainerUri)" -sasToken "$(GenerateSasToken.SasToken)"'
    deploymentOutputs: ARMoutput
  timeoutInMinutes: 60

Inside the Master_Deployment_Template i have defined the SasToken variable and Im creating the URI like this "uri": "[concat(parameters('LinkedTemplatesBaseUrl'),parameters('DataBricks'),'/',parameters('DataBricks'), '_Deployment_Template.json',parameters('sasToken'))]"

URI seems to be correct https://mystoragaccount.blob.core.windows.net/arm/Databricks/Databricks_Deployment_Template.json*** , also seems like its passing my SAS token since there is the ***

Not sure I do I still get the invalidlink error, is the authentication issue?


Solution

  • It seems the URL of your target file is wrong. Checking the Blob SAS URL in my Azure Storage, it is something like https://{storageName}.blob.core.windows.net/{containerName}/test.json?{SASToken} . According to your URL, there is a folder "Databricks" in your container "arm", not sure if it's correct. Besides, you are missing a ? between your file URL and the SAS token.

    Please go to your storage and check whether your URL is correct or not.