无法在我的一台Azure虚拟机上正确运行Azure自动化作业(RunBook). [英] Failure to get Azure Automation job (RunBook) running properly on one of my Azure Virtual Machines.

查看:111
本文介绍了无法在我的一台Azure虚拟机上正确运行Azure自动化作业(RunBook).的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试获取Azure自动化作业(RunBook)以在我的其中一个Azure虚拟机上正常运行.

I have been trying to get an Azure Automation job (RunBook) to run properly on one of my Azure Virtual Machines.

 

在此先感谢您的帮助.

Thanks in advance for your help.

 

到目前为止,我在哪里:

Where I am an so far:

 

我已经成功创建了一个AzureRunAsConnection,并成功地完成了运行Azure作业的教程.

I've successfully created an AzureRunAsConnection and worked through the tutorials successfully having run an Azure job.

 

我认为我会尽力完成实际的任务,在这种情况下,PowerShell脚本会杀死正在运行的进程,并且启动计划任务以再次启动它.

I figured I'd try to get an actual task done, in this case a PowerShell script that will kill a running process and the kick of a scheduled task to start it back up again.

 

我已经成功地从本地工作站上的PowerShell将此脚本运行到我要与Azure联系的同一Azure主机上自动化工作,因此我非常有信心在 权限设置正确.例如,我确信启用了PowerShell远程管理,因为它可以工作.

I've successfully run this script from PowerShell on my local workstation to the same Azure host I'm trying to reach with my Azure Automation job, so I'm pretty confident that it does work when the permissions are setup correctly. For example, I'm confident that PowerShell remote management is enabled because it works.

 

我怀疑我在尝试连接到我的AzureRunAsConnection所在的安全内容时遇到权限问题Azure VM.  我无法集中精力解决这些连接/凭据如何转换为在Azure VM上实际执行操作的权限.

I suspect that I've got a permissions problem with the security content that the AzureRunAsConnection is running under when it attempts to connect to my Azure VM.  I'm having trouble wrapping my brain around how these connections/credentials translate to permissions to actually do something on an Azure VM.

 

它在get进程中失败,因此其他所有操作都会失败.

It's failing on the get-process so everything else fails.

 

这是我正在运行的脚本.

Here is the script that I'm running.

  

  

连接类型: AzureServicePrincipal名为-> AzureRunAsConnection

Connection type:    AzureServicePrincipal named -> AzureRunAsConnection

Runbook类型: PowerShell Runbook

Runbook type:    PowerShell Runbook

  
$ Conn = Get-AutomationConnection -Name AzureRunAsConnection
Connect-AzureRmAccount -ServicePrincipal -Tenant $ Conn.TenantID -ApplicationId $ Conn.ApplicationID -CertificateThumbprint $ Conn.CertificateThumbprint
$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Connect-AzureRmAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint

推荐答案

在Azure自动化帐户中,您无法直接调用虚拟机,需要声明虚拟机资源详细信息. HTTPS

In Azure Automation account you can’t directly call the vm, you need declare vm resources details.you need use HTTPS to connect Azure VMs.

步骤:

steps:
1. Create a self-signed certificate.

Use  makecert.exe

Use makecert.exe to create it.

2.Config Winrm收听 HTTPS ,并在CMD中运行此脚本:

2.Config Winrm listen on HTTPS, run this script in CMD:

winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Port="5986" ;Hostname="vm" ;CertificateThumbprint="00000000000000000000000000000000000000000"}


3. 在Azure NSG入站规则和Windows防火墙入站规则中添加端口5986.


3. Add port 5986 in Azure NSG inbound rules and windows firewall inbound rules.

示例:


connectionName = "AzureRunAsConnection"; 尝试 {     #获取连接 "AzureRunAsConnection"    
connectionName = "AzureRunAsConnection" try {     # Get the connection "AzureRunAsConnection "    


servicePrincipalConnection = Get-AutomationConnection -Name
servicePrincipalConnection=Get-AutomationConnection -Name


这篇关于无法在我的一台Azure虚拟机上正确运行Azure自动化作业(RunBook).的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆