如何使用Azure批处理和数据工厂中的Azure Analysis Services进行身份验证 [英] How to authenticate with Azure Analysis Services from Azure batch and data factory

查看:95
本文介绍了如何使用Azure批处理和数据工厂中的Azure Analysis Services进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个c Sharp类库,该库使用AMO库连接到Azure Analysis Services。

I have a c sharp class library that connects to Azure Analysis Services using the AMO library.

我想将此作为我的数据工厂管道的一部分来刷新多维数据集分区。这是通过Azure批处理作为自定义.net活动完成的。

I'd like to use this as part of my data factory pipeline to refresh cube partitions. This is done through Azure batch as a custom .net activity.

var server = new Server();
server.Connect("Provider=MSOLAP;Data Source=asazure://uksouth.asazure.windows.net/abcd;Initial Catalog=xyz");

在本地运行此方法效果很好,但是不会在云中运行。由于它不在我的用户帐户下运行,因此当前错误。我知道我可以在连接字符串中添加用户名和密码,但是如果可能的话,我宁愿给它某种授权。

Running this locally works fine, however this will not run in the cloud. It currently errors out as it is not being run under my user account. I know that I can add a username and password to the connection string, but I would much rather give it some form of authorisation if that is possible.

还有其他方法吗?

推荐答案

现在可以使用服务帐户连接到AAS。

It's possible to connect to AAS using service account now.

请参阅自定义活动的工作示例此处

See working example of custom activity here.

连接部分可以简化为:

var authority = "https://login.windows.net/<tenant-id>";
var resource = "https://southcentralus.asazure.windows.net";
var appId = "***";
var appSecret = "***";

AuthenticationContext authContext = new AuthenticationContext(authority);
ClientCredential credentials = new ClientCredential(appId, appSecret);
var task = authContext.AcquireTokenAsync(resource, credentials);
task.Wait();
string token = task.Result.AccessToken;

var connectionStringTemplate = "Provider=MSOLAP;Data Source=asazure://southcentralus.asazure.windows.net/xxxxxx;Initial Catalog= xxx;User ID=;Password={0};Persist Security Info=True;Impersonation Level=Impersonate";
var connectionString = string.Format(CultureInfo.InvariantCulture, connectionStringTemplate, token);

var server = new Server();
server.Connect(connectionString);

您需要以 app格式授予服务帐户访问AAS模型的权限: < appId> @< tenantId>

这篇关于如何使用Azure批处理和数据工厂中的Azure Analysis Services进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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