How can we run multiple CLI command in Azure Bash together?

Viewed 1609

I have Multiple Resources to deploy in my Environment using CLI command all together. For Example: I need to create VM, Web App, Redis Cache, etc using a single script. Instead of creating individual resources can we create all together.

1 Answers

One way is to put all your commands in a .sh shell script. Below is an example of how you can do this:

#!/bin/bash

az group create -n MyResourceGroup -l centralus

az vm create -n MyVm -g MyResourceGroup --image UbuntuLTS

az webapp create -g MyResourceGroup -p MyPlan -n MyUniqueAppName

# More Azure CLI commands to create resources

Then you can run your script inside your local environment bash shell or Azure Cloud Shell like this:

username@Azure:~$ ./script.sh

Another way is to use an ARM template to deploy your resources.

Related