This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hi,
I am using code that was written for Microsoft Analysis Service, I changed my connection string to another server which is holding PBI Datasets inside. The code seems to work, but since there is a 2 way authentication process in my team, the code can't run from a machine.
I want to use a token instead. Will this remove the need for the other authentication?
If so - what is the proper way to connect with the token?
I succeeded on getting the token, but I can't find the proper way to connect with it.
Right now the code looks like -
Microsoft.AnalysisServices.Server server = new Microsoft.AnalysisServices.Server();
try
{
server.Connect(string.Format("Data source={0};", serverName));
}...
What am I missing?
Thanks
Hi @sonsi ,
You can refer the following links to connect to an Analysis Services server using a token in C#:
Get the access token:
How to get Azure Access Token using C# - JD Bots (jd-bots.com)
Connection:
c# - How to authenticate with Azure Analysis Services from Azure batch and data factory
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);
Best Regards
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 9 | |
| 5 | |
| 3 | |
| 3 | |
| 2 |