Hello @Nasimjon Tohirov
If you find that the az vm run-command invoke command is too slow for your needs, you can consider using a custom script extension to install Docker on the VM after it has been deployed. Here's an example of how you can use a custom script extension to install Docker on a Linux VM:
Create a shell script that installs Docker. For example, you can create a file named install-docker.sh with some similar contents as below
#!/bin/bash
# Install Docker
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
# Add the current user to the docker group
sudo usermod -aG docker $USER
Upload the script to a public URL. For example, you can upload the script to a GitHub repository and use the raw URL.Create a custom script extension for the VM.
Azure CLI command to create the extension:
az vm extension set \ --resource-group <resource-group-name> \ --vm-name <vm-name> \ --name customScript \ --publisher Microsoft.Azure.Extensions \ --version 2.1 \ --settings '{"fileUris":["<script-url>"],"commandToExecute":"./install-docker.sh"}'
Replace <resource-group-name>
and <vm-name>
with the name of your resource group and VM, respectively. Replace <script-url>
with the URL of the script you uploaded in step 2.
Wait for the extension to complete. You can monitor the status of the extension using the following Azure CLI command:
az vm extension list \ --resource-group <resource-group-name> \ --vm-name <vm-name> \ --query "[].{Name:name, ProvisioningState:provisioningState, Status:status.message}" \ --output table
Reference
https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-linux