0

I am trying to do an ARM deployment using bash but getting this error

ArgumentUsageError: argument --template-uri/-u: expected one argument

What am I doing wrong here?

- task: AzureCLI@2
  inputs:
    azureSubscription: 'Pay-As-You-Go'
    scriptType: 'bash'
    scriptLocation: 'inlineScript'
    inlineScript: |
      armTemplateURI=$('https://xxxx.blob.core.windows.net/temp/Function-Deployment.json?'$(SASTOKEN))
      packageURI=$('https://xxxxx.blob.core.windows.net/fileupload/PrdFunctions.zip?'$(SASTOKEN))
      output=$(az deployment group create --name "Function-Deployment" --resource-group "rg-dev-xxxx" --template-uri $armTemplateURI --parameters appName="fapp-dev-xxxx" storageName="stgdevxxxx" location="Australia East" cosmosName="cosmos-xxxx" msdeployPackageUrl=$packageURI)
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
FarhanK
  • 71
  • 1
  • 3
  • Are there supposed to be ```
    ```?
    – ewokx Jan 13 '21 at 01:15
  • There is most like a space somewhere in `$armTemplateURI`, try building this variable in another task then printing it out to the console to narrow down the issue. – Matt Stannett Jan 13 '21 at 02:03
  • You can try to change the commands like this `armTemplateURI='https://xxxx.blob.core.windows.net/temp/Function-Deployment.json?'$SASTOKEN`. – Charles Xu Jan 13 '21 at 02:40
  • Hi Charles, Thanks it worked. just wondering why my variable did not work? I'll try Matt's suggestion. Thank you all once again. – FarhanK Jan 13 '21 at 04:26

1 Answers1

0

As I see, the document Set secret variables shows the way to set the secret in a secure way. And in bash, you do not need to use the $() to set a string as the value of a variable. So the right way for you should like this:

- task: AzureCLI@2
    inputs:
        azureSubscription: 'Pay-As-You-Go'
        scriptType: 'bash'
        scriptLocation: 'inlineScript'
        inlineScript: |
            armTemplateURI='https://xxxx.blob.core.windows.net/temp/Function-Deployment.json?'$MY_SASTOKEN
            packageURI='https://xxxxx.blob.core.windows.net/fileupload/PrdFunctions.zip?'$MY_SASTOKEN
            output=$(az deployment group create --name "Function-Deployment" --resource-group "rg-dev-xxxx" --template-uri $armTemplateURI --parameters appName="fapp-dev-xxxx" storageName="stgdevxxxx" location="Australia East" cosmosName="cosmos-xxxx" msdeployPackageUrl=$packageURI)
        env: 
            MY_SASTOKEN: $(SASTOKEN)
Charles Xu
  • 29,862
  • 2
  • 22
  • 39