Photon OS integrated manufacturing capabilities are used inside of many VMware Virtual Appliances software products. The open source standalone Linux operating system runs on VMware infrastructure as well as a secure, container workloads optimized virtual machine on public cloud infrastructure.
In blog post Part1 we walked through a straightforward public cloud Microsoft Azure introduction as the interoperability is the main topic of this blog series. To provision an Azure Photon OS virtual machine inside of our precreated resources we learned to specify our environment with the resource model parameters
- resourcegroup
- location
- storageaccount
- create a storage container when uploading files
- virtual network with at least a subnet
Similar to vSphere CLI and PowerCLI for administrators, Azure CLI and Azure Powershell provide useful interaction cmdlets. You can download Azure CLI from here(Windows) or here (navigation page of install the Azure CLI), and use install-module -name Az for the Azure Powershell installation.
Let's go through the following study script.
# # change current directory to the .vhd file path of the locally extracted Photon OS binary j: cd j:\photon-azure-3.0-9355405.vhd.tar # create a resourcegroup $LocationName="switzerlandnorth" $ResourceGroupName="photonoslab-rg" new-azresourcegroup -name $ResourceGroupName -location $LocationName # create a storageaccount $StorageAccountName="photonosaccount" new-azstorageaccount -ResourceGroupName $ResourceGroupName -name $StorageAccountName ` -location $LocationName -kind storage -skuname Standard_LRS $storageaccountkey=(get-azstorageaccountkey -ResourceGroupName $ResourceGroupName -name $StorageAccountName) # create a virtual network with at least a subnet $vnetaddressprefix="192.168.0.0/16" $subnetaddressprefix="192.168.1.0/24" $singlesubnet=new-azvirtualnetworkSubnetConfig -Name frontendSubnet -AddressPrefix $subnetaddressprefix $vnet = new-AzVirtualNetwork -name "photonos-network" -ResourceGroupName $ResourceGroupName ` -Location $LocationName -AddressPrefix $vnetaddressprefix -Subnet $SingleSubnet $vnet | set-AzVirtualNetwork # create a storage container when uploading files $containername="disks" az storage container create --name ${containername} --public-access blob ` --account-name $StorageAccountName --account-key ($storageaccountkey[0]).value # upload $vhdfile=".\photon-azure-3.0-9355405.vhd" $blobname="photon-azure-3.0-9355405.vhd" az storage blob upload --account-name $StorageAccountName --account-key ($storageaccountkey[0]).value ` --container-name ${Containername} --type page --file $vhdfile --name ${BlobName} # create a network interface $NiName="photonNI" $nic = New-AzNetworkInterface -Name $NiName -ResourceGroupName $ResourceGroupName ` -Location $LocationName -SubnetId $vnet.Subnets[0].Id # create the Azure Photon OS virtual machine using the offer Standard_B1ms (1 vCPU, 2 GB RAM) [System.Management.Automation.Credential()]$VMLocalcred = (Get-credential -message ` 'Enter username and password for the Azure Photon OS virtual machine local user account to be created. ` Password must be at least 12 characters long. Be aware of upper case and lowercase letters in username.') $vmSize="Standard_B1ms" $vmName="photon" $URLOfUploadedVhd="https://${StorageAccountName}.blob.core.windows.net/${ContainerName}/${BlobName}" az vm create --resource-group ${ResourceGroupName} --location ${LocationName} --name ${vmName} --size ${VMSize} ` --storage-account ${StorageAccountName} --storage-container-name ${ContainerName} --nic $NiName ` --image ${URLOfUploadedVhd} --use-unmanaged-disk --os-type linux --computer-name ${vmName} ` --admin-username $($VMLocalcred.GetNetworkCredential().username) --admin-password $($VMLocalcred.GetNetworkCredential().password) ` --generate-ssh-keys --boot-diagnostics-storage https://${StorageAccountName}.blob.core.windows.net Get-AzVM -ResourceGroupName $ResourceGroupName -Name $vmName
Line 2-5: The Photon OS Azure .vhd file must be downloaded and extracted to a local directory. On a Windows machine you can use tools like 7zip to extract the .vhd file from the .tar.gz binary. We change the current directory to the photon os vhd file directory path as the az vm create cmdlet in the version used has some culprits if the working directory does not match with the current path.
Line 6-10: creation of the resourcegroup. Change value of params resourcegroup name and location.
Line 11-16: creation of the storage account. Change value of param storageaccountname.
Line 17-24: creation of a virtual network with a single subnet. Change value of params vnetaddressprefix and subnetaddressprefix. Both require CIDR annotation.
Line 25-34: creation of a storage container and upload of the .vhd file. Change value of param containername. The value of param vhdfile must be the .vhd filename. The value of param blobname must have the filename extension .vhd as prerequisite for the az vm create parameter --image.
Line 35-39: precreate an Azure network interface for our Azure Photon OS virtual machine. Change value of param NiName.
The common arguments of cmdlet New-AzNetworkInterface are ResourceGroupname and Location, and with the precreated subnet and the specified network interface name.
Why do we create first an Azure network interface and not the virtual machine?
In vSphere, a Virtual Standard vSwitch (VSS) port in use is not the virtual nic adapter of the 1:1 connected ESXi VM. In vSphere the port in use is in some sort a virtual function of its VM as no other VM can use this port simultaneously. Using the PowerCLI cmdlet new-networkadapter you directly specify the VM and the VirtualNetworkAdapterType. In a distributed vSwitch scenario you can additionally specify a port to which you want connect the new network adapter.
This distinguation is necessary as in Azure you create a ~network interface virtual function when using new-aznetworkinterface, with no need to bind it directly to a vm.
Let's go through the next code lines.
Line 40-52:create the Azure Photon OS virtual machine using the offer Standard_B1ms. Change value of param vmName.
In the SDDC way, you can create your own Photon OS ISO with factory defaults for computername, username and password for any flavor of on-premise and cloud-based installation. The built-in Microsoft Azure Linux Agent (waagent) of the Photon OS Azure .vhd minimal installation processes the az vm create params --computer-name, and --admin-username and --admin-password. Specify as value of param VMLocalCred credentials for a local useraccount to be created. The username cannot be the user root. You can change the root password in the post configuration.
We already uploaded the Photon OS Azure .vhd file in our precreated storage container. The storage container blob got an url https://${StorageAccountName}.blob.core.windows.net/${ContainerName}/${BlobName}. This url is passed in az vm create as value of argument –image.
In part1 we've specified for the Azure Photon OS lab the storageaccount argument -type storage and -sku Standard_LRS. 'Good enough' in the younger Azure days mean "okay, please specify 'good enough'". You get charged for any type of operation, from compute, ram, storage to network resources in use. To get an idea about storage SLA's underlying OLA components have a look to the information about storage container (page) blobs and disks here.
Page blobs writes and reads are billed on a per transaction-basis. Estimate a low bandwidth data stream with every minute one 64KB createContainer operation and every minute ten 64KB getBlob operation. The cost insight pricing estimation a year actually would be 2 Swiss francs for all ~ 32GB writes, and read operations.
As --os-type we specify Linux. Prerequisites for a minimal Photon OS virtual machine installation are
- 2GB of free RAM (recommended)
- 512MB of free storage space (minimum)
As virtual machine size I use a minimal, burstable B-series offering Standard_B1ms with 1 CPU core, 2GB RAM, 4GB temporary storage (SSD) and with moderate network throughput. Change value of param vmSize to your needs.
An Azure virtual machine console isn't enabled by default. We specify the argument --boot-diagnostics-storage for enabling console interaction.
The argument --generate-ssh-keys is optional, as in this study script we will connect through the Azure serial console for Linux. .--generate-ssh-keys creates ssh public and privat key files in the /root/.ssh directory.
Line 53: As powershell output we will see the created Azure Photon OS virtual machine.
I hope you have enjoyed part2. Please reach out in case of questions or suggestions. Finally in part3 we start with configuring Photon OS.