【问题标题】:Can't run Azure data factory from Azure function无法从 Azure 函数运行 Azure 数据工厂
【发布时间】:2018-06-29 09:54:30
【问题描述】:

这是我的 c# Azure Function 脚本:

#r "System.Runtime"
#r "System.Threading.Tasks"
using System;
using System.Net;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Microsoft.Azure;
using Microsoft.Azure.Management.DataFactory;
using Microsoft.Azure.Management.DataFactory.Models;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Rest;

public static void Run(TimerInfo myTimer, TraceWriter log)
{
    log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
    /*...All variable definations...*/


var authenticationContext = new AuthenticationContext(activeDirectoryEndpoint + activeDirectoryTenantld);    
ClientCredential credential = new ClientCredential(clientld, clientSecret);    
AuthenticationResult result = authenticationContext.AcquireTokenAsync(windowsManagementUri, credential).Result; 
ServiceClientCredentials cred = new TokenCredentials(result.AccessToken);
var client = new DataFactoryManagementClient(cred) { SubscriptionId = subscriptionId };

Dictionary<string, object> arguments = new Dictionary<string, object>
            {
                { "bufferdays", 10 },
                {"TimeToCopy", 20 }
            };    
CreateRunResponse runResponse = client.Pipelines.CreateRunWithHttpMessagesAsync(resourceGroupName, dataFactoryName, pipelineName,arguments).Result.Body;

}

这会引发错误run.csx(56,130): error CS1503: Argument 4: cannot convert from 'System.Collections.Generic.Dictionary' to 'string' .但同样的事情在 Visual Studio 中也能正常工作。这里有什么问题?

【问题讨论】:

    标签: c# azure azure-functions azure-data-factory-2


    【解决方案1】:

    知道了。

    I was using {
      "frameworks": {
        "net46":{
          "dependencies": {
    
            "Microsoft.Azure.Management.DataFactory": "0.8.0",
    

    在 project.json 中,它自动下载了 1.0.0 版。我不得不通过明确指定 "Microsoft.Azure.Management.DataFactory": "0.8.0-preview", 来强制它下载 0.8.0 版。

    【讨论】:

      猜你喜欢
      • 2021-08-29
      • 1970-01-01
      • 2021-03-08
      • 2019-11-24
      • 1970-01-01
      • 2020-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多