2

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.

Voval Jain
  • 25
  • 1
  • 5
  • Based on your requirements, I would actually recommend making use of ARM Templates and create all resources using a single template. – Gaurav Mantri Mar 25 '20 at 06:05
  • You just need to put all your CLI commands that you used to create the resources inside a single shell script and execute it. But first, you need to log in for the CLI. – Charles Xu Mar 25 '20 at 07:11

1 Answers1

3

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.

RoadRunner
  • 25,803
  • 6
  • 42
  • 75