How to run AZ CLI 2.0 on Octopus Server

rsingh's Avatar

rsingh

30 Jun, 2017 02:56 AM

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

https://docs.microsoft.com/en-us/azure/cosmos-db/scripts/create-mongodb-database-account-cli?toc=%2fcli%2fazure%2ftoc.json

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.

  1. Support Staff 1 Posted by Dalmiro Grañas on 30 Jun, 2017 04:58 PM

    Dalmiro Grañas's Avatar

    Hi,

    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 :)

    Best regards,
    Dalmiro

  2. Paul Stovell closed this discussion on 25 Oct, 2017 02:03 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac