Keep in mind that this was a manual action. There you go! Your Windows 365 Cloud PC is rebooted via Azure Automation. Open your Azure Automation Account -> Runbooks -> W365-Reboot -> Startĭevices -> All Devices -> Select Device -> Device actions status $mypwd = ConvertTo-SecureString -String " $cert = New-SelfSignedCertificate -Subject "CN=$certname" -CertStoreLocation "Cert:\CurrentUser\My" -KeyExportPolicy Exportable -KeySpec Signature -KeyLength 2048 -KeyAlgorithm RSA -HashAlgorithm SHA256Įxport-Certificate -Cert $cert -FilePath "$ExportPath\W365-Automation.cer" #Create Certificate and Export Private Key In this case you need to sync your GitHub modifications manually. If you don’t like the auto sync feature, just remove the parameter from the script. When using this parameter all modifications within the Source ( GitHub) are automatically synced into the Azure Automation Runbook. We make use of the -EnableAutoSync parameter. If you are using a different branch in your GitHub Repository this should be changed. The -Branch parameter is main by default.If you create a folder named “Runbook” there’s no need to change anything. This is the path where your actual code is stored within the GitHub Repository. The -FolderPath parameter must probably be changed.This is the access token used to access the GitHub Repository. $SecString should be modified to the Personal Access Token which you created before.New-AzRoleAssignment -ObjectId $RoleAssignment.id -RoleDefinitionName "Contributor" -ResourceGroupName $RGName -WarningAction:Silentl圜ontinueĬonfigure Source Control in the Azure Automation Account. $RoleAssignment = Get-AzADServicePrincipal -DisplayName $MiName #Assign contributor permissions to the Managed Identity New-AzAutomationModule -AutomationAccountName $AutomationAccount -ResourceGroupName $RGName -Name $moduleName4 -ContentLinkUri "$moduleName4/$moduleVersion4"Ĭreate a User Assigned Managed Identity based on the parameters shown above. New-AzAutomationModule -AutomationAccountName $AutomationAccount -ResourceGroupName $RGName -Name $moduleName3 -ContentLinkUri "$moduleName3/$moduleVersion3" New-AzAutomationModule -AutomationAccountName $AutomationAccount -ResourceGroupName $RGName -Name $moduleName2 -ContentLinkUri "$moduleName2/$moduleVersion2" Write-Host "Required module is installed. If ($ModuleState.ProvisioningState -eq "Succeeded") Write-host (get-date) "Required module is installing. While ((Get-AzAutomationModule -AutomationAccountName $AutomationAccount -ResourceGroupName $RGName -Name $moduleName).ProvisioningState -ne "Succeeded") Continue if PrivisioningState is "Succeeded" New-AzAutomationModule -AutomationAccountName $AutomationAccount -ResourceGroupName $RGName -Name $moduleName -ContentLinkUri "$moduleName/$moduleVersion" Install required modules and Connect to AzAccount and AzureAD. All the steps (including what should be modified is shown below in steps. Note: Some parts should be modified for yourself. The complete script can be found here in my GitHub. I figured out all the steps required and put them together in a script. The complete Azure Infrastructure required, can be deployed via command line. Note: Write-down the Personal Access Token! We need this later! Deploy Azure Automation When using GitHub, the following PAT permissions are required: Create a Personal Access Token: Creating a personal access token – GitHub Enterprise Server 3.4 Docs.Create a GitHub Repository: Create a repo – GitHub Docs.Therefor I had to create a Repository and a Personal Access Token. Source Control can import (sync) data from the following sources: With Source Control you can store data elsewhere and sync the data (scripts/code) into your Azure Automation Runbook’s. Azure Automation Runbooks can import code from a local (device) path and can make use of Source Control. Github Repo (Source Control)īecause I was looking for an automated deployment I had to make sure I could store my code somewhere. I talk you trough this in the blog below. There are some steps which have to be done manually. Azure Automation Account (with Runbook).Github repository (with Personal Access Token).The code is shared in the “ Deploy Azure Automation” part of this blog. Therefor I wrote some code which completely deploys the infrastructure parts required. There are really, many, many prerequisites needed for this to work. Probably there’s no need to but it sounded like a great idea for a new blog! Curious how it’s done? Continue reading! Prerequisites Somehow, there’s no built-in option available to reboot Cloud PC’s overnight. For performance purposes I would like to reboot and/or reprovision Windows 365 Cloud PC’s on a recurring schedule. Since a while I’m testing/playing around with Windows 365 Cloud PC’s. Code to initiate the Reboot (with Azure Automation).
0 Comments
Leave a Reply. |