<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Connecting through c# in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Connecting-through-c/m-p/3457143#M44782</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use a token instead. Will this remove the need for the other authentication?&lt;/P&gt;&lt;P&gt;If so - what is the proper way to connect with the token?&lt;/P&gt;&lt;P&gt;I succeeded on getting the token, but I can't find the proper way to connect with it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now the code looks like -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;                Microsoft.AnalysisServices.Server server = new Microsoft.AnalysisServices.Server();

                try
                {
                    server.Connect(string.Format("Data source={0};", serverName));
}...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I missing?&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Oct 2023 07:02:47 GMT</pubDate>
    <dc:creator>sonsi</dc:creator>
    <dc:date>2023-10-03T07:02:47Z</dc:date>
    <item>
      <title>Connecting through c#</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Connecting-through-c/m-p/3457143#M44782</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use a token instead. Will this remove the need for the other authentication?&lt;/P&gt;&lt;P&gt;If so - what is the proper way to connect with the token?&lt;/P&gt;&lt;P&gt;I succeeded on getting the token, but I can't find the proper way to connect with it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now the code looks like -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;                Microsoft.AnalysisServices.Server server = new Microsoft.AnalysisServices.Server();

                try
                {
                    server.Connect(string.Format("Data source={0};", serverName));
}...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I missing?&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 07:02:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Connecting-through-c/m-p/3457143#M44782</guid>
      <dc:creator>sonsi</dc:creator>
      <dc:date>2023-10-03T07:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: Connecting through c#</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Connecting-through-c/m-p/3461062#M44814</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/615180"&gt;@sonsi&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;You can refer the following links to&amp;nbsp;&lt;SPAN&gt;connect to an Analysis Services server using a token in C#:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Get the access token:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://jd-bots.com/2020/06/22/how-to-get-azure-access-token-using-c/" target="_blank"&gt;How to get Azure Access Token using C# - JD Bots (jd-bots.com)&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Connection:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://endjin.com/blog/2020/02/azure-analysis-services-how-to-open-a-connection-from-net" target="_blank"&gt;Azure Analysis Services: How to open a connection from .NET | endjin - Azure Data Analytics Consultancy UK&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://stackoverflow.com/questions/44133724/how-to-authenticate-with-azure-analysis-services-from-azure-batch-and-data-facto" target="_blank"&gt;c# - How to authenticate with Azure Analysis Services from Azure batch and data factory&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;var authority = "https://login.windows.net/&amp;lt;tenant-id&amp;gt;";
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);&lt;/LI-CODE&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 06:29:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Connecting-through-c/m-p/3461062#M44814</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-05T06:29:47Z</dc:date>
    </item>
  </channel>
</rss>

