无法使用Azure Automation Runbook中的Connect-MsolService连接到O365-HttpRequestException [英] Unable to connect to O365 using Connect-MsolService from Azure Automation Runbook - HttpRequestException

查看:89
本文介绍了无法使用Azure Automation Runbook中的Connect-MsolService连接到O365-HttpRequestException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试使用Azure Automation Runbook中的MSonline连接到O365环境.

我的Runbook中只有这两行-

$ credObject = Get-AutomationPSCredential-名称"MSOnline-Credentials"
Connect-MsolService-凭据$ credObject

MSOnline-Credentials凭据是具有对O365环境的Admin访问权限的AD Admin凭据.我可以使用完全相同的凭据从PowerShell连接.

但是,当我尝试运行该作业时,我遇到了错误

 

Connect-MsolService:发送请求时发生错误. 第2行char:1 + Connect-MsolService-凭证$ cred + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:OperationStopped :( :) [Connect-MsolService],HttpRequestException + FullyQualifiedErrorId: System.Net.Http.HttpRequestException,Microsoft.Online.Administration.Automation.ConnectMsolService

我无法找到有关HTTP请求出了什么问题的详细信息.寻找有关此的任何指导.

我们是否需要在O365方面采取任何特殊措施来允许来自Azure自动化等的请求?我使用的凭据直接在自动化帐户中创建,而不是在身份运行方式"中创建.这有什么区别吗?从错误来看,它不会 似乎是一个凭证问题.请指导.

谢谢

Partha

解决方案

您好,ParthaKS,如果我理解正确,则2行cmd可在本地工作,但一旦上载到Azure自动化则会失败帐户.也许您需要安装 有关在Azure自动化中更新模块的更多信息.


Hi Everyone,

I am trying to connect to the O365 environment using MSonline from Azure Automation Runbook.

I just have these two lines in my Runbook - 

$credObject = Get-AutomationPSCredential -Name "MSOnline-Credentials"
Connect-MsolService -Credential $credObject

The MSOnline-Credentials credential is a AD Admin credential that has Admin access to the O365 environment. I am able to connect from my PowerShell with exact same credentials.

However, when I try to run the job, I am getting below error

Connect-MsolService : An error occurred while sending the request. At line:2 char:1 + Connect-MsolService -Credential $cred + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [Connect-MsolService], HttpRequestException + FullyQualifiedErrorId : System.Net.Http.HttpRequestException,Microsoft.Online.Administration.Automation.ConnectMsolService

I am unable to find details about what went wrong with the HTTP request. Looking for any guidance regarding this. 

Do we require any special actions on O365 side to allow the request from Azure Automation etc? The credentials I have used are created in the automation account directly and not Run As Credentials. Does this make any difference? From the error, it doesnt seem to be a credential issue. Please guide.

Thanks,

Partha

解决方案

Hello ParthaKS, If I understand correctly, the 2 line cmd works locally but fails once uploaded to the Azure Automation account. Perhaps you need to install the MS Online Module on the Automation account.

Go here for more information on updating modules in Azure Automation.


这篇关于无法使用Azure Automation Runbook中的Connect-MsolService连接到O365-HttpRequestException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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