简体   繁体   English

如何使用 Azure Functions、Runbooks 或 Azure Powershell 在 Azure 虚拟机中执行程序?

[英]How execute a program in a Azure Virtual Machine using Azure Functions, Runbooks or Azure Powershell?

I need to start an application / file sometimes a day on a Windows Virtual Machine on Azure and I don't want to make an RDP connection to do this whenever I need to run it.我有时需要每天在 Azure 上的 Windows 虚拟机上启动一个应用程序/文件,并且我不想在需要运行它时建立 RDP 连接来执行此操作。 So, I would like to know if it is possible to create an Azure Function, Runbook (Automation) or script in Powershell to open this application / file (and schedule, if possible).因此,我想知道是否可以在 Powershell 中创建 Azure 函数、Runbook(自动化)或脚本来打开此应用程序/文件(如果可能,还有计划)。

I tried the following script on Automation Runbooks, but it didn't work:我在自动化 Runbooks 上尝试了以下脚本,但没有奏效:

$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Add-AzureRMAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint
$VMs = Get-AzureRMVM | where {$_.Tags.Values -like '*TaggedMachine*'} 
$VMs | Start-Process -FilePath "notepad.exe"
Write-Output $VMs.Name

You can try to use Azure VMs Run Command functionality.您可以尝试使用 Azure VM 运行命令功能。 If you are using Azure PowerShell just see this: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/run-command#powershell如果您使用的是 Azure PowerShell,请查看: https : //docs.microsoft.com/en-us/azure/virtual-machines/windows/run-command#powershell

If you are using AzureRM module, use this command instead: https://docs.microsoft.com/en-us/powershell/module/azurerm.compute/invoke-azurermvmruncommand?view=azurermps-6.13.0如果您使用AzureRM模块,请改用此命令: https : AzureRM

if you need more help, just let me know:)如果您需要更多帮助,请告诉我:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM