Search code examples
azureazure-devopsdevopsazure-powershellcicd

Azure VM: Stoping Azure VM after creation in a CI CD pipeline task


I've been trying to solve this problem for almost two days and i need your help.

I created an Azure Pipeline on Azure DEvops that deploys a bunch of resources amongst them an Azure VM (I plan to add later more VMs), and i added an Azure Powershell task to stop the VM right after the Terraform Apply task in the YAML config file of my pipeline.

here is the two YAML tasks of Terraform Apply and Azure Powershell: enter image description here

I tried the 'Install-Module Az.Compute' but my pipeline displayed this error :

Pipeline error message : enter image description here

Any suggestions on this issue will be very helpful !


Solution

  • The reason of the error was a typo in the Az Powershell command: Correct command

    Get-AzVM | Stop-AzVM -Force
    

    instead of :

    Get-AzureVM | Stop-AzVM -Force
    

    When in doubt always visit the Microsoft documentation : Az.Compute Module | Microsoft Learn