Reputation: 249
I am attempting to install an artifact through an azure VM - I have remoted into the VM through the powershell on azure and am running the following command:
Enter-AzVm -Name <MyVM> -ResourceGroupName <MyResourceGroup> -Credential (get-credential)
When I'm connected onto the VM I'm attempting this download command which works on my local machine:
az artifacts universal download --organization <MyOrganization> --project=<MyProject> --scope project --feed <MyFeed> --name <MyFirstPackage> --version 0.0.1 --path .
This is the error I'm getting while attempting that download :
The term 'az' is not recognized as the name of a cmdlet, function, script file, or operable program
I tried to run the command to install CLI on the VM which runs, but after that installation run I cannot see az --version with the same error. Any help would be appreciated.
Upvotes: 0
Views: 741
Reputation: 42123
I have never used Enter-AzVm
to remote into the VM to install Azure CLI, seems the Enter-AzVm
just works in Azure Cloud Shell(not sure).
I installed the Azure CLI successfully via Invoke-AzVMRunCommand
command in a Windows VM, when I test az --version
in cloud shell after remoting into the VM with Enter-AzVm
, it works fine, you could follow the steps below.
1.Save the command below in local as a installcli.ps1
file.
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi
2.Run the command below in local.
Invoke-AzVMRunCommand -ResourceGroupName 'groupname' -VMName 'vmname' -CommandId 'RunPowerShellScript' -ScriptPath 'C:\Users\joyw\Desktop\installcli.ps1'
3.After the command completed, navigate to the cloud shell, use Enter-AzVm
to remote into the VM, then run az --version
, it works fine.
Actually, if the steps above not work for you, you can also store the azure cli command as a .ps1
file like step 1
, then use Invoke-AzVMRunCommand
to run it, it will work.
Upvotes: 1