First script is PowerShell to repath a scene file from Windows to Linux, package all the assets, upload them, create a VM, and open an SSH session.
Script number two is run in said session. It downloads the project, extracts it to the right folders, kicks off a render, uploads the results and shuts down the VM when done.
This particular script is for Maya, but it should work similarly with any other DCC or renderer.
I censored a few potentially sensitive Azure tokens and paths. Feel free to ask about anything and share your solutions too!
PowerShell
# define variables param([string]$project) $root_path="c:/onedrive/main_projects" $token="##########################################################" $geo=$root_path+"/geo/commercial/"+$project+"/*.usd" $geo_dest=$env:TEMP+"/bhgc/"+$project+"/geo/commercial/"+$project+"/" $tex=$root_path+"/tex/commercial/"+$project+"/*.*" $tex_dest=$env:TEMP+"/bhgc/"+$project+"/tex/commercial/"+$project+"/" $scene=$root_path+"/scenes/"+$project+".ma" $scene_dest=$env:TEMP+"/bhgc/"+$project+"/" # make destination folders if (-not (Test-Path -LiteralPath $geo_dest)) { mkdir $geo_dest } if (-not (Test-Path -LiteralPath $tex_dest)) { mkdir $tex_dest } # update paths in project file (Get-Content $scene).Replace("C:/onedrive","/home/brian") | Set-Content $scene # copy files to assembly folder copy-item $geo $geo_dest -Recurse copy-item $tex $tex_dest -Recurse copy-item $scene $scene_dest -Recurse # archive scene $7z=$env:TEMP+"/bhgc/"+$project+"/"+$project+".7z" $7z_contents=$env:TEMP+"/bhgc/"+$project+"/*" 7z a -t7z $7z $7z_contents # copy archive to Azure azcopy copy $7z "######################################################" # delete local archive Remove-Item -Recurse -Force "$env:TEMP/bhgc/*" # create VM $template="C:\onedrive\Scripts\azure\vm_templates\tem_lin_96_spot.json" $param="C:\onedrive\Scripts\azure\vm_templates\param_lin_96_spot.json" Connect-AzAccount -TenantId ##################################### Write-Host -ForegroundColor Green "Deploying..." New-AzResourceGroupDeployment -ResourceGroupName linux -TemplateFile $template -TemplateParameterFile $param Write-Host -ForegroundColor Green "Deployed. Pausing for 60 seconds..." Start-Sleep -Seconds 60 $vm_ip=(Get-AzPublicIpAddress -Name "##################").IpAddress Write-Host -ForegroundColor Green "`nInitiating SSH connection...`n" ssh ################@$vm_ip
Bash
project=$1 token="############################" proj_file="${project}.7z" root_path="/home/brian/main_projects" azcopy copy "########################" "/home/brian/main_projects/" cd $root_path 7z x -y ${root_pth}/${proj_file} mkdir -p ${root_path}/render/commercial/${project}/ Render -rd "${root_path}/render/commercial/${project}/" ${project}.ma azcopy copy "${root_path}/render/commercial/${project}/" "#############################" --recursive --overwrite=ifSourceNewer echo -e "\e[32mDone! Shutting down in 60 seconds...\n\e[0m" sudo shutdown