Articles → MICROSOFT AZURE → Run A Custom Script From GitHub In The Linux Machine

Run A Custom Script From GitHub In The Linux Machine






GitHub




  1. Create a new repository myrepo
  2. Create a new file with the name install_web.sh
  3. Inside the file install_web.sh, write the following command
  4. apt-get update -y && apt-get upgrade -y
    apt-get install -y nginx


  5. Commit the file install_web.sh
  6. Get the raw URL of the file
  7. Picture showing the code inside the file install_web.sh for installing nginx
    Click to Enlarge



Customscript.Json File




{
  "fileUris": [
    "https://raw.githubusercontent.com/guptakaran21/myrepo/main/install_web.sh"
  ],
  "commandToExecute": "./install_web.sh"
}



Run Script In The Powershell




  1. Open the cloud shell in the Azure portal
  2. In the PowerShell mode, upload the customscript.json
  3. Picture showing the upload menu for uploading a file in Azure cloudshell
    Click to Enlarge

  4. Inside the PowerShell, execute the following command
  5. az vm extension set --resource-group RG --vm-name myvm --name customScript --publisher Microsoft.Azure.Extensions --settings customscript.json




Picture showing the custom script provisioned in Extensions in virtual machine
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, April 21, 2021

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250