terça-feira, março 12, 2024

Azure DevOps

Situation: The Azure DevOps pipeline runs daily, and a new VM (with the same name and configuration) is created each time. The VM creation is based on the snapshot.

Issue: Due to the pipeline configuration, every time the machine was deleted and recreated, we encountered problems related to the Active Directory machine trust, because the machine was a domain member.

Solution: Remove the VM from the Active Directory, create a new snapshot (in the state where the machine is in the workgroup), change the pipeline, and remove and add the machine to the domain every time the pipeline runs.

These are the steps:

 

 

Important: We are using self-hosted agent, which is member of the domain.

These are the code for the steps below:

RemoveADComputerObject

Add VM To Domain (I am using the Azure extension to run a Powershell script):

az vm run-command invoke --resource-group rg --name 'computername' --command-id 'RunPowerShellScript' --scripts "C:\ADJoin\ADDDomain.ps1"

Remove File:

az vm run-command invoke --resource-group devops --name 'qa-fresh' --command-id 'RunPowerShellScript' --scripts 'Remove-Item -Path "C:\ADJoin\ADDDomain.psa1" -Force'


 

 

domingo, novembro 26, 2023

Oracle OCI Bastion - Windows

Simple tips on connecting to a Windows VM running in a private subnet in the Oracle OCI Cloud. The first step is to create the bastion and link it to the VCN/Subnet:


Create a session, select the instance and past your SSH Key:

 

After creating the session, copy the SSH command. On your computer, replace the values; I used port 1000:
 

 

Open your RDP client and enter 'localhost' along with the port you've chosen:

 

Done!