Open project-oagent-gh-app[bot] opened 1 month ago
Below is the bash script that creates the required files:
#!/bin/bash
# Creates the bash script file
echo "#!/bin/bash
# Install Azure CLI
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
# Install .Net Core SDK
wget https://download.visualstudio.microsoft.com/download/pr/95e91e8e-496e-4f22-8d12-573aa5aa67f6/32cc5f113a3a10f6e6c4d8a4e2d6f203/dotnet-sdk-3.1.100-preview3-014645-linux-x64.tar.gz
mkdir -p \$HOME/dotnet && tar zxf dotnet-sdk-3.1.100-preview3-014645-linux-x64.tar.gz -C \$HOME/dotnet
export DOTNET_ROOT=\$HOME/dotnet
export PATH=\$PATH:\$HOME/dotnet
# Create a resource group for the VM
az group create --name myResourceGroupAutomate --location eastus
# Create the VM
az vm create \
--resource-group myResourceGroupAutomate \
--name myAutomatedVM \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys \
--custom-data cloud-init.txt
# Install Nginx using custom script extension
az vm extension set \
--resource-group myResourceGroupAutomate \
--vm-name myAutomatedVM \
--name customScript \
--publisher Microsoft.Azure.Extensions \
--settings '{\"commandToExecute\": \"apt-get install -y nginx\"}'" > setup.sh
# Creates the cloud-init file
echo "#cloud-config
package_upgrade: true
packages:
- nginx" > cloud-init.txt
# Changes the permissions of the bash script to make it executable
chmod +x setup.sh
Please note that this script is creating a bash script named setup.sh
that contains the tasks and a cloud-init file named cloud-init.txt
that is used to install Nginx during the virtual machine creation. The script also makes the bash script executable. To run the bash script, you can use ./setup.sh
command.
{ 'code': "# Install Azure CLI curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
Install .Net Core SDK
wget https://download.visualstudio.microsoft.com/download/pr/95e91e8e-496e-4f22-8d12-573aa5aa67f6/32cc5f113a3a10f6e6c4d8a4e2d6f203/dotnet-sdk-3.1.100-preview3-014645-linux-x64.tar.gz mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-3.1.100-preview3-014645-linux-x64.tar.gz -C $HOME/dotnet export DOTNET_ROOT=$HOME/dotnet export PATH=$PATH:$HOME/dotnet" }