Azure VM Custom Data and User Data
- Custom Data and User Data are the scripts that can be executed while VM is being created (Provisioned)
- User Data is latest version of Custom Data where Azure Instance Metadata Service is accessible
- Steps
#!/bin/bash
apt update
apt install apache2 stress -y
apt install php libapache2-mod-php php-mysql -y
echo '<?php phpinfo(); ?>' > /var/www/html/info.php
systemctl restart apache2
- Lets create an Azure VM with the above as user data
Preparation
- Create a ubuntu linux vm
- Become a root user
sudo -i
- Execute the following commands
apt update
apt install apache2 stress -y
apt install php libapache2-mod-php php-mysql -y
echo '<?php phpinfo(); ?>' > /var/www/html/info.php
systemctl restart apache2
- From the VM Created above, we can create resuable images.
- Azure Supports creating reusable images in two ways
- Azure managed Image
- Azure Compute Gallery
Generalized and Specialized VM Images
- Azure Generalized VM allows users to set credentials while provisioning, whereas specialized VM images don’t allow to set credentials
- Azure Managed Image:
- This creates Generalized VM Images
- Azure Compute Gallery
- This creates both Generalized as well as specialized VM Images
- Note: If we need to create Generalized VM Image, the user specific information has to be removed, so the source vm becomes unusable.
Create a Managed Image
- Click Capture
-
Now lets try to create a vm with the captured image
-
Note:
- Learn JSON Refer Here