Open project-oagent-gh-app[bot] opened 4 months ago
You can achieve this by using the following bash script. This script uses Azure CLI commands to setup a VM and install the required software. Note: it assumes that you have Azure CLI installed on your machine and you're authenticated with Azure account.
#!/bin/bash
# Create Resource Group
az group create --name myResourceGroupAutomate --location eastus
# Create cloud-init.txt file
echo "#cloud-config
package_upgrade: true
packages:
- nginx" > cloud-init.txt
# Create VM with cloud-init file
az vm create --resource-group myResourceGroupAutomate --name myAutomatedVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keys --custom-data ./cloud-init.txt
# Install Visual Studio Code
az vm run-command invoke --resource-group myResourceGroupAutomate --name myAutomatedVM --command-id RunShellScript --scripts "wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -" "sudo add-apt-repository 'deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main'" "sudo apt-get install apt-transport-https -y" "sudo apt-get update" "sudo apt-get install code -y"
# Install .NET Core SDK
az vm run-command invoke --resource-group myResourceGroupAutomate --name myAutomatedVM --command-id RunShellScript --scripts "wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb" "sudo dpkg -i packages-microsoft-prod.deb" "sudo apt-get update" "sudo apt-get install -y apt-transport-https" "sudo apt-get update" "sudo apt-get install -y dotnet-sdk-3.1"
# Install Azure CLI
az vm run-command invoke --resource-group myResourceGroupAutomate --name myAutomatedVM --command-id RunShellScript --scripts "curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash"
This script does the following things:
cloud-init.txt
with cloud configuration to install nginx.Remember to replace myResourceGroupAutomate
, myAutomatedVM
, and azureuser
with your actual resource group name, VM name, and admin username. Also, make sure to run this script from a directory that has write permissions, as it creates a new file cloud-init.txt
in the current directory.
Write a script to install Visual Studio community edition, .NET Core SDK and the Azure CLI tool on your development machine.