Azure CLI Task - Can't run more than 1 command?
See original GitHub issueIs there some sort of arbitrary limit on Azure CLI task to only run 1 command? Is this a bug or feature?
Below code:
az --version ;
az group create --name "$RSGROUP" --location $REGION ;
az vm create -n $VMname --image CentOS -g $RSGROUP --size $VMsize ;
Results in only the first command running (az --version ;
in this case):
2017-08-25T17:34:18.4671741Z ##[section]Starting: AZ CLI: Create VM
2017-08-25T17:34:18.4681743Z ==============================================================================
2017-08-25T17:34:18.4681743Z Task : Azure CLI Preview
2017-08-25T17:34:18.4681743Z Description : Run a Shell or Batch script with Azure CLI commands against an azure subscription
2017-08-25T17:34:18.4681743Z Version : 1.0.2
2017-08-25T17:34:18.4681743Z Author : Microsoft Corporation
2017-08-25T17:34:18.4681743Z Help : [More Information](http://go.microsoft.com/fwlink/?LinkID=827160)
2017-08-25T17:34:18.4681743Z ==============================================================================
2017-08-25T17:34:18.6961853Z az group create --name "$RSGROUP" --location $REGION ;
2017-08-25T17:34:18.6961853Z
2017-08-25T17:34:18.6961853Z az vm create -n $VMname --image CentOS -g $RSGROUP --size $VMsize ;
2017-08-25T17:34:18.7021851Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Python36-32\Scripts\az.bat" login --service-principal -u ******** -p ******** --tenant ********"
2017-08-25T17:34:22.4067133Z [
2017-08-25T17:34:22.4067133Z {
2017-08-25T17:34:22.4067133Z "cloudName": "AzureCloud",
2017-08-25T17:34:22.4067133Z "id": "**scrubbed**",
2017-08-25T17:34:22.4067133Z "isDefault": true,
2017-08-25T17:34:22.4067133Z "name": "**scrubbed**",
2017-08-25T17:34:22.4067133Z "state": "Enabled",
2017-08-25T17:34:22.4067133Z "tenantId": "********",
2017-08-25T17:34:22.4067133Z "user": {
2017-08-25T17:34:22.4067133Z "name": "********",
2017-08-25T17:34:22.4067133Z "type": "servicePrincipal"
2017-08-25T17:34:22.4067133Z }
2017-08-25T17:34:22.4067133Z }
2017-08-25T17:34:22.4077135Z ]
2017-08-25T17:34:22.4077135Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Python36-32\Scripts\az.bat" account set --subscription "**scrubbed**""
2017-08-25T17:34:24.7374767Z [command]C:\Windows\system32\cmd.exe /D /S /C "d:\a\_temp\azureclitaskscript1503682458696.bat"
2017-08-25T17:34:24.7434772Z
2017-08-25T17:34:24.7434772Z d:\a\r1\a>az --version ;
2017-08-25T17:34:25.3215529Z azure-cli (2.0.14)
2017-08-25T17:34:25.3215529Z
2017-08-25T17:34:25.3225062Z acr (2.0.10)
2017-08-25T17:34:25.3225062Z acs (2.0.13)
2017-08-25T17:34:25.3225062Z appservice (0.1.13)
2017-08-25T17:34:25.3225062Z batch (3.1.1)
2017-08-25T17:34:25.3225062Z billing (0.1.3)
2017-08-25T17:34:25.3225062Z cdn (0.0.6)
2017-08-25T17:34:25.3225062Z cloud (2.0.7)
2017-08-25T17:34:25.3225062Z cognitiveservices (0.1.6)
2017-08-25T17:34:25.3225062Z command-modules-nspkg (2.0.1)
2017-08-25T17:34:25.3225062Z component (2.0.7)
2017-08-25T17:34:25.3225062Z configure (2.0.10)
2017-08-25T17:34:25.3225062Z consumption (0.1.3)
2017-08-25T17:34:25.3225062Z container (0.1.8)
2017-08-25T17:34:25.3225062Z core (2.0.13)
2017-08-25T17:34:25.3225062Z cosmosdb (0.1.11)
2017-08-25T17:34:25.3225062Z dla (0.0.10)
2017-08-25T17:34:25.3225062Z dls (0.0.12)
2017-08-25T17:34:25.3225062Z eventgrid (0.1.2)
2017-08-25T17:34:25.3225062Z feedback (2.0.6)
2017-08-25T17:34:25.3225062Z find (0.2.6)
2017-08-25T17:34:25.3225062Z interactive (0.3.7)
2017-08-25T17:34:25.3225062Z iot (0.1.10)
2017-08-25T17:34:25.3225062Z keyvault (2.0.8)
2017-08-25T17:34:25.3225062Z lab (0.0.9)
2017-08-25T17:34:25.3225062Z monitor (0.0.8)
2017-08-25T17:34:25.3225062Z network (2.0.12)
2017-08-25T17:34:25.3225062Z nspkg (3.0.1)
2017-08-25T17:34:25.3225062Z profile (2.0.10)
2017-08-25T17:34:25.3225062Z rdbms (0.0.5)
2017-08-25T17:34:25.3225062Z redis (0.2.7)
2017-08-25T17:34:25.3225062Z resource (2.0.12)
2017-08-25T17:34:25.3225062Z role (2.0.10)
2017-08-25T17:34:25.3225062Z sf (1.0.6)
2017-08-25T17:34:25.3235057Z sql (2.0.9)
2017-08-25T17:34:25.3235057Z storage (2.0.12)
2017-08-25T17:34:25.3235057Z vm (2.0.12)
2017-08-25T17:34:25.3235057Z
2017-08-25T17:34:25.3235057Z Python (Windows) 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)]
2017-08-25T17:34:25.3235057Z
2017-08-25T17:34:25.3235057Z Python location 'C:\Program Files\Python36\python.exe'
2017-08-25T17:34:25.3235057Z
2017-08-25T17:34:26.7287247Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Python36-32\Scripts\az.bat" account clear"
2017-08-25T17:34:28.7336033Z ##[section]Finishing: AZ CLI: Create VM
edit: Adding batch and command + escape character allows “multiple commands” but what really is one liner. ie. this below works:
az group create --name %RSGROUP% --location %REGION% &^
az vm create -n %VMNAME% --image CentOS -g %RSGROUP% --size %VMSIZE% --generate-ssh-keys
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to split a CLI command in Azure Devops over multiple ...
from azure cloud shell, type AZ, then copy paste the az command with \ for multiple line will not work. but there is...
Read more >Tips for using the Azure CLI successfully - Microsoft Learn
First choose the right command-line tool and install the Azure CLI. Then use this article to discover useful tips on how to avoid...
Read more >CmdLine@2 - Command line v2 task - Microsoft Learn
Run a command line script using Bash on Linux and macOS and cmd.exe on Windows.
Read more >Azure DevOps CLI in Azure Pipeline YAML - Microsoft Learn
The steps in this article show how to authenticate with Azure DevOps and run az devops commands using the Azure DevOps CLI extension....
Read more >How to install and manage Azure CLI extensions
Extensions for the Azure CLI are characterized as Python wheels that aren't shipped as part of the CLI but run as CLI commands....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Since you’re running it on a windows agent; you need to add
call
in front of each command to execute all of them.You should replace your current inline script with this;
If you were running it in a Linux environment, the
call
should be removed. This is how batch scripts run multiple commands otherwise it would be treated as a oneliner.Why cannot we not just create a script file with azcli with out the call statement - very clunky to add call to every statement !?!?!?!