使用 Azure 自动化在 Azure Linux VM 上执行 bash 命令

Execute bash commands on Azure Linux VM using azure automation

我需要使用 Ubuntu 映像在 Azure VM 上安装软件。手动执行此操作的一种方法是使用 putty 或其他命令行工具通过 ssh 进入终端并执行安装 bash 命令。另一种方法是通过创建 bash 脚本并从 Azure 自动化调用它来实现自动化。但是我无法找到从 azure automation 运行books 调用 bash 脚本的方法。如果可行,请告诉我。

我能够调用 powershell 脚本,因为 Azure Automation 默认支持 powershell。

我尝试使用命令 New-SshSession 并使用 Invoke-SshCommand 到 运行 我的命令,但在尝试连接到会话时出现以下错误。

此外,使用 New-SshSession(见下文)的先决条件是什么?

New-SshSession -ComputerName 'ComputerName' -Username 'UserName'

Unable to create SSH client object: Exception calling ".ctor" with "4" argument(s): "Could not load type 'System.Security.Cryptography.HMACRIPEMD160' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral,

在开始使用 New-SshSession 之前是否有任何先决条件?我需要在我的 linux 机器上安装任何 .Net 库吗?

欢迎来到 Stack Overflow!!

如果要求是针对 Windows VM,那么利用 Invoke-AzVmRunCommand cmdlet but as requirement is for Linux VM so looks like the comment (with sample script) provided by Azure Automation team content author in this GitHub 可以很容易地帮助您完成在 Azure 上执行 bash 命令的要求Linux 使用 Azure 自动化的 VM。

希望对您有所帮助!!