在 Azure Automation Runbook 中 运行 时,Submit-AdlJob 失败并显示找不到方法

Submit-AdlJob fails with Method not Found when running in Azure Automation Runbook

我正在尝试通过 Azure 自动化服务在 Azure Data Lake Analytics 上安排一些我以前 运行 的 U-SQL 脚本(我也曾尝试在 ADF 中执行此操作,但它也对我不起作用,我将制定另一个问题来解决该路径)。

这是基于 MS Docs Guidance 的简化 运行 书籍代码,对我来说仍然有错误:

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

$adla = "example_adla01"

$script = @"
@a  = 
    SELECT * FROM 
    (VALUES
        ("Contoso", 1500.0),
        ("Woodgrove", 2700.0)
    ) AS D( customer, amount );
OUTPUT @a
TO "/data.csv"
USING Outputters.Csv();
"@

Submit-AdlJob -AccountName $adla -Script $script -Name "Demo"

被调用命令的版本。

CommandType  Name            Version   Source
-----------  ----            -------   ------                                    
Alias        Submit-AdlJob   4.2.3     AzureRM.DataLakeAnalytics   

这项工作 运行 在我本地的 Powershell ISE 和 Cloud Shell 中没问题;但在 Azure 自动化服务测试中失败 运行ner 并出现此错误(已更新以包含更详细的错误):

Submit-AzureRmDataLakeAnalyticsJob : A command that prompts the user failed because the host program or the command type does not support user interaction. The host was attempting to request confirmation with the following message: 

Method not found: 'Newtonsoft.Json.Serialization.IAttributeProvider 
Newtonsoft.Json.Serialization.JsonProperty.get_AttributeProvider()'.
At line:23 char:1

+ Submit-AzureRmDataLakeAnalyticsJob -AccountName $adla -Script $script ...    
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotImplemented: (:) [Submit-AzureRmDataLakeAnalyticsJob], HostException
+ FullyQualifiedErrorId : HostFunctionNotImplemented,Microsoft.Azure.Commands.DataLakeAnalytics.SubmitAzureDataLakeAnalyticsJob

我已经导入了我认为是正确的模块,但一直无法找到与 JSON 相关的任何其他模块,或者为什么 JSON Serializer 被调用,这是否则我今天早上站起来的全新自动化实例。

命令的调试输出:

7:04:53 PM - SubmitAzureDataLakeAnalyticsJob begin processing with ParameterSet 'SubmitUSqlJob'.

7:04:53 PM - using account id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'...
[Common.Authentication]: Authenticating using Account: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', environment:  'AzureCloud', tenant: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 

04/23/2018 19:04:54:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - AcquireTokenForClientHandler: === Token Acquisition started:
    Authority: https://login.microsoftonline.com/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/
    Resource: https://management.core.windows.net/
    ClientId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (1 items)
    Authentication Target: Client


Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - <RunAsync>d__0: Looking up cache for a token...
Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - TokenCache: An item matching the requested resource was found in the cache
Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - <RunAsync>d__0: 59.9101559033333 minutes left until token in cache expires
Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - <RunAsync>d__0: A matching item (access token or refresh token or both) was found in the cache
Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :

04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - AcquireTokenHandlerBase: === Token Acquisition finished 
successfully. An access token was retuned:
    Access Token Hash: //removed
    Refresh Token Hash: [No Refresh Token]
    Expiration Time: 04/23/2018 20:04:48 +00:00
    User Hash: null


Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 04/23/2018 19:04:54:  - AuthenticationStoreTokenCache: Serializing token cache with 1 items.

[Common.Authentication]: Authenticating using Account: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', environment: 'AzureCloud', tenant: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - AcquireTokenForClientHandler: === Token Acquisition started:
    Authority: https://login.microsoftonline.com/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/
    Resource: https://datalake.azure.net/
    ClientId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (1 items)
    Authentication Target: Client
Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - <RunAsync>d__0: Looking up cache for a token...
Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - <RunAsync>d__0: No matching token was found in the cache
Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - <RunAsync>d__0: Storing token in the cache...
Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - <RunAsync>d__0: An item was stored in the cache

Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :

04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
    Access Token Hash: //removed
    Refresh Token Hash: [No Refresh Token]
    Expiration Time: 04/23/2018 20:04:53 +00:00
    User Hash: null

Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 04/23/2018 19:04:54:  - AuthenticationStoreTokenCache: Serializing token cache with 2 items.
[Common.Authentication]: Authenticating using Account: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', environment: 'AzureCloud', tenant: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 

04/23/2018 19:04:54: 1cdd67fa-ce99-4931-b1aa-4ced126fa018 - AcquireTokenForClientHandler: === Token Acquisition started:
    Authority: https://login.microsoftonline.com/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/
    Resource: https://datalake.azure.net/
    ClientId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (2 items)
    Authentication Target: Client


Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - <RunAsync>d__0: Looking up cache for a token...
Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - TokenCache: An item matching the requested resource was found in the cache
Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - <RunAsync>d__0: 59.9828124866667 minutes left until token in cache expires
Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - <RunAsync>d__0: A matching item (access token or refresh token or both) was found in the cache
Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :

04/23/2018 19:04:54: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
    Access Token Hash: //remove
    Refresh Token Hash: [No Refresh Token]
    Expiration Time: 04/23/2018 20:04:53 +00:00
    User Hash: null

Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 04/23/2018 19:04:54:  - AuthenticationStoreTokenCache: Serializing token cache with 2 items.

除了 Matt 的评论之外,您能否尝试通过删除所有模块并仅导入 AzureRM.DataLakeAnalytics 来刷新模块?导入 AzureRM.DataLakeAnalytics 应该会自动导入 AzureRM.Profile,这是唯一的依赖模块。

尝试删除(或重命名)您在 C:\Windows\Assembly\GAC 中的所有 newtonsoft.json.dll 文件和 C:\Windows\Assembly\GAC_MSIL 目录。

看起来自从我打开这个问题后发生了变化,现在我得到了不同的(更有用的错误消息)。

Environments                                                                                                            
------------                                                                                                            

{[AzureUSGovernment, AzureUSGovernment], [AzureChinaCloud, AzureChinaCloud], 
[AzureGermanCloud, AzureGermanCloud], [A...
Submit-AzureRmDataLakeAnalyticsJob : The user is not authorized to perform this operation on storage.

At line:21 char:1
+ Submit-AzureRmDataLakeAnalyticsJob -AccountName $adla -Script $script ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : CloseError: (:) [Submit-AzureRmDataLakeAnalyticsJob], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.DataLakeAnalytics.SubmitAzureDataLakeAnalyticsJob

我必须添加 Azure Automation RunAs 帐户才能访问底层 Azure Data Lake Storage 帐户,因为虽然它从作为订阅的贡献者继承了对计算的访问权限,但它没有获得对Azure 数据湖存储帐户。

我是从 Azure Data Lake 做的 "Add user wizard"

我现在看到 Azure 自动化用户能够针对 Azure Data Lake Analytics Blade 中的作业管理器触发作业。