Search code examples
azure-devopsazure-cli

How to split a CLI command in Azure Devops over multiple lines? (Running on Windows)


I am running the following in a CLI task on Azure Devops (inline)

rem Create the Service Plan
call az appservice plan create --resource-group %RESOURCE_GROUP% --name %SERVICE_NAME% --sku B1

Whch works just fine. However, I'm having to scroll to see the whole thing and I have other commands which are even longer. So I'm trying to split it over multiple lines so I can see more clearly what is going on.

Looking at Microsoft Docs it looked like the solution was to put a backslash on the end of each line. So I tried:

I've tried:

rem Create the Service Plan
call az appservice plan create \
--resource-group %RESOURCE_GROUP% \
--name %APP_SERVICE_NAME% \
--sku B1

Which didn't work. I then read something that recommended the back-tick/back-quote at the end of each line:

rem Create the Service Plan
call az appservice plan create `
--resource-group %RESOURCE_GROUP% `
--name %APP_SERVICE_NAME% `
--sku B1

This also didn't work. Any help greatly appreciated.


Solution

  • Never mind. Worked it out. Turns out you need to use '^'

    rem Create the Service Plan
    call az appservice plan create ^
    --resource-group %RESOURCE_GROUP% ^
    --name %APP_SERVICE_NAME% ^
    --sku B1