繁体   English   中英

无法使用Visual Studio 2015运行Azure数据工厂管道

[英]Not able to run Azure Data Factory Pipeline using Visual Studio 2015

我已遵循Azure文档步骤来创建从Blob到SQL的简单复制数据工厂。

现在,我想通过VS代码运行管道。 我已经检查了身份验证密钥和分配的角色是否正确。

下面是代码-

var context = new AuthenticationContext("https://login.windows.net/" + tenantID);
ClientCredential cc = new ClientCredential(applicationId, authenticationKey);
AuthenticationResult result = context.AcquireTokenAsync("https://management.azure.com/", cc).Result;
ServiceClientCredentials cred = new TokenCredentials(result.AccessToken);
var client = new DataFactoryManagementClient(cred) { SubscriptionId = subscriptionId };

Console.WriteLine("Creating pipeline run...");
var st = client.Pipelines.Get(resourceGroup, dataFactoryName, pipelineName);
CreateRunResponse runResponse = client.Pipelines.CreateRunWithHttpMessagesAsync(resourceGroup, dataFactoryName, pipelineName).Result.Body;
Console.WriteLine("Pipeline run ID: " + runResponse.RunId);

但是,我得到Forbidden error

对象ID为'xxxx'的客户端'xxxx'没有权限在范围'/ subscriptions / xxxxx / resourceGroups /'上执行操作'Microsoft.DataFactory / factories / pipelines / read'

我怎样才能解决这个问题?

我怎样才能解决这个问题?

根据异常消息,它表明您没有为应用程序分配相应的角色来访问数据工厂。

我使用Azure Datafactory(V2)来测试您的代码,它可以正常工作。 以下是我的详细步骤。

  1. 注册一个Azure AD WebApp应用程序

  2. 从创建的Application中获取clientId和clientcret

  3. 为角色分配应用程序以访问数据工厂。

在此处输入图片说明

  1. 测试代码在我这边。

    在此处输入图片说明

暂无
暂无

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

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