簡體   English   中英

az vm run-command invoke 在 azure 虛擬機上安裝軟件命令失敗

[英]az vm run-command invoke installing software on azure virtual machine command fails

我有一個 arm 模板成功配置 azure 虛擬機,配置后我需要在虛擬機上安裝一些軟件包。 我目前正在執行此操作的方式是通過以下命令。

Set-AzVMCustomScriptExtension -ResourceGroupName "xxx" -VMName "xx" -Name "ChocoInstall" -FileUri "https://community.chocolatey.org/install.ps1" ` -Run "install.ps1" -Location "xx"

一旦安裝了巧克力,下一步就是安裝一些軟件包。

我在這里找到了類似的答案,我正在嘗試使用相同的命令。

az vm run-command invoke -g "xxx"  -n "xx" --command-id RunpowerShellScript --scripts "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" ; "choco install notepadplusplus"

然后我得到下面的錯誤。

"code": "ComponentStatus/StdErr/succeeded", "displayStatus": "Provisioning succeeded", "level": "Info", "message": "choco: The term 'choco' is not recognized as the name of a cmdlet, function, script file, or operable program. Check \nthe spelling of the name, or if a path was included, verify that the path is correct and try again.\nAt C:\\Packages\\Plugins\\Microsoft.CPlat.Core.RunCommandWindows\\1.1.11\\Downloads\\script2.ps1:3 char:1\n+ choco install notepadplusplus\n+ ~~~~~\n + CategoryInfo: ObjectNotFound: (choco:String) [], CommandNotFoundException\n + FullyQualifiedErrorId: CommandNotFoundException\n ", "time": null } ] }

我已經在我的環境中復制並成功了,我遵循了Microsoft-DocumentM QandA ,下面是我使用的命令,我得到了預期的結果如下:

 az vm run-command invoke -g MyResourceGroup  -n MyVm --command-id RunpowerShellScript  --scripts "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))"  ;  "choco install -y python3"

在此處輸入圖像描述

嘗試choco install -y ,如果不起作用,請嘗試Chocolatey install -y

示例:在 linux 虛擬機中安裝 nginx:

az vm run-command invoke -g MyResourceGroup -n MyVm --command-id RunShellScript --scripts "sudo apt-get update && sudo apt-get install -y nginx"

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM