Cloud Rendering: Azure via PowerShell [4.5/5] (Patreon)
Content
Before we move on to the final section of this tutorial, I wanted to quickly talk about some important tools for interacting with Azure via Windows PowerShell. Since we're trying to automate as much of this process as possible we don't want to visit the Azure dashboard or log into our VM's GUI at any point.
Fortunately, everything we need to do can be done from PowerShell! To get started, follow the setup instructions here, halfway down and under the Windows PowerShell tab. (The default version of PS on most Windows systems is Windows PowerShell. PowerShell 7 is the open-source, cross-platform version of PS. If you happen to have that, follow that guide instead.)
Once you're all set up, the first thing to do is log PowerShell into Azure. This can done by typing:
Connect-AzAccount -TenantId <tenant ID here>
You can find your Tenant ID by visiting the Azure dashboard, typing "tenant" into the search bar, and selecting the Tenant properties option.
PowerShell will ask for your Azure credentials. After logging in we'll be able to fully modify and control our VMs from the command line.
To check the status of our rendering VM, type the following (substituting the relevant resource group and VM name if needed):
Get-AzVM -ResourceGroupName "linux" -Name "render" -Status
"Deallocated" means that the VM is currently turned off.
To start or stop the VM, use these commands (-Force when stopping simply bypasses the confirmation request):
Start-AzVM -ResourceGroupName "linux" -Name "render"Stop-AzVM -ResourceGroupName "linux" -Name "render" -Force
When we log into the VM via SSH later on, we'll need to get its IP address. To do that, we can assign the VM "object" to a variable like this:
$vm_ip = Get-AzPublicIpAddress -Name "render-ip" -ResourceGroupName "linux"
Note that the -Name parameter in this case is "render-ip." Azure always automatically creates an occurrence of your VM name with the "-ip" suffix.
To test if it worked, print the IP address by typing:
$vm_ip.IpAddress
Finally, we'll want to be able to easily resize our VM. The tiny 2 cVPU one we've been using for setup purposes is not going to render anything very fast! The cheapest 96 vCPU VM in my region is Standard_D96as_v4 at about 46 cents per hour. To change to this size, type:
$vm = Get-AzVM -ResourceGroupName "linux" -Name "render"$vm.HardwareProfile.VmSize = "Standard_D96as_v4"Update-AzVM -ResourceGroupName "linux" -VM $vm
That's all there is to it! To confirm the resize worked, type:
$vm = Get-AzVM -ResourceGroupName "linux" -Name "render"$vm.HardwareProfile
Success!
With that housekeeping out of the way, we're well-equipped to start rendering. On to Part 5!