Search code examples
windowsazure-resource-managerazure-cliazure-deployment

az deployment does not work with SAS tokens for template-uri


I use the current Azure CLI (2.0.50) on Windows in powershell. I tried to deploy an ARM template with an template-uri which is stored in azure blob storage. This uri for the template file contains an SAS token...

If I pass the uri with the SAS token to az group deployment create it gives the following error: HTTP Error 404: The specified resource does not exist. Der Befehl "sp" ist entweder falsch geschrieben oder konnte nicht gefunden werden. Der Befehl "sv" ist entweder falsch geschrieben oder konnte nicht gefunden werden. Der Befehl "sr" ist entweder falsch geschrieben oder konnte nicht gefunden werden. Der Befehl "sig" ist entweder falsch geschrieben oder konnte nicht gefunden werden.

The template uri looks like: https://blobname.blob.core.windows.net/templates/resgroup/root.json?se=2018-11-16T11%3A58Z&sp=r&sv=2018-03-28&sr=c&sig=signature

It seems that the parameter seperator (&) is treated as a special character...

How can I pass an SAS token as template-uri?


Solution

  • Put the value of the --template-uri parameter in single quotes. Put each ampersand in that string inside double-quotes.

    --template-uri 'https://blobname.blob.core.windows.net/templates/resgroup/root.json?se=2018-11-16T11%3A58Z"&"sp=r"&"sv=2018-03-28"&"sr=c"&"sig=signature'

    Means you'll need to do some string processing before calling the CLI.

    Using the Azure cmdlets would work too. In any case, I'm curious about your scenario for using the CLI in PS.