无法使用Azure数据工厂(ADF)创建链接服务, 我对ADF级别的链接服务有读/写权限。
var data = google.visualization.arrayToDataTable([
['Kenmerk', 'Belangrijkheid', {label: 'tooltip', role: 'tooltip'},{ role: 'style' } ],
BTW我同时使用了客户端凭证和用户凭证
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.DataFactory;
using Microsoft.Azure.Management.DataFactory.Models;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
LinkedServiceResource storageLinkedService = new
LinkedServiceResource(
new AzureStorageLinkedService
{
ConnectionString = new
SecureString("DefaultEndpointsProtocol=https;AccountName=" +
storageAccount + ";AccountKey=" + storageKey)
}
);
client.LinkedServices.CreateOrUpdate(resourceGroup,
dataFactoryName, storageLinkedServiceName, storageLinkedService);
ClientCredential cc = new ClientCredential(applicationId,
authenticationKey);
var cc = new UserPasswordCredential(userName, password);
Microsoft.Azure.Management.DataFactory.Models.ErrorResponseException:
Operation returned an invalid status code 'Forbidden'
at Microsoft.Azure.Management.DataFactory.LinkedServicesOperations.
<CreateOrUpdateWithHttpMessagesAsync>d__6.MoveNext() --- End of stack
trace from previous location where exception was thrown ---
答案 0 :(得分:0)
根据您的异常,您似乎使用来自Web客户端的资源所有者流。机密客户端(例如Web App客户端)无法使用直接用户凭据。
您需要将其作为公共客户端(本机客户端应用程序)调用,而不是作为机密客户端(Web应用程序/ API)。有关如何使用ADAL的更多信息,请参阅此document,尤其是约束&amp;限制部分
没有网站/机密客户端 这不是ADAL限制,而是AAD设置。您只能使用来自本机客户端的那些流。机密客户端(如网站)无法使用直接用户凭据。
要访问订阅中的资源,您需要assign role to the registried App.
请尝试使用以下内容获取TokenCredentials,以下是创建墨水服务的演示代码。它在我身边正常工作。我们也可以参考这个document。
private static async Task<string> GetToken(string tenantId, string clientId, string secretKey)
{
var context = new AuthenticationContext("https://login.windows.net/" + tenantId);
ClientCredential clientCredential = new ClientCredential(clientId, secretKey);
var tokenResponse = await context.AcquireTokenAsync("https://management.azure.com/", clientCredential);
var accessToken = tokenResponse.AccessToken;
return accessToken;
}
var token = GetToken(_tenantId, _clientId, _screctKey).Result;
TokenCredentials credentials = new TokenCredentials(token);
DataFactoryManagementClient client = new
DataFactoryManagementClient(credentials) { SubscriptionId = subscriptionId };
DataFactoryManagementClient client = new DataFactoryManagementClient(credentials) { SubscriptionId = subscriptionId };
LinkedServiceResource storageLinkedService = new LinkedServiceResource(new AzureStorageLinkedService{
ConnectionString = new SecureString("DefaultEndpointsProtocol=https;AccountName=" + storageAccount + ";AccountKey=" + storageKey)});
var result =client.LinkedServices.CreateOrUpdateWithHttpMessagesAsync(resourceGroup, factoryName, storageLinkedServiceName, storageLinkedService).Result;