How to run AZ CLI 2.0 on Octopus Server

We are provision Azure Cosmos DB Account via an arm template.
After the DB account has been created we need to create a Database and Collections.
Currently, Azure PowerShell SDK does not support creating cosmos db document and collections.
So my only choice is to use az cli.

Create a database

az cosmosdb database create
–name $name
–db-name $databaseName
–resource-group $resourceGroupName

Create a collection

az cosmosdb collection create
–collection-name $collectionName
–name $name
–db-name $databaseName
–resource-group $resourceGroupName

We already have a tentacle installed on the octopus deploy server.
I am planning on installing az cli on the octopus server and use script step to create database and collection.
In the script I will login
az login --service-principal -u http://sample-cli-login -p Test1234 --tenant 54826b22-38d6-4fb2-bad9-b7b93a3e9c5a

and execute 2 commands above.

I am wondering if this will work. I don’t have a lot of time and I don’t want to spend time on this if there are problems with this approach.


Thanks for reaching out! If you install the tool in the server where you’ll be running the commands, I don’t see a reason why It wouldn’t work :slight_smile:

Best regards,