I am refreshing a data model in Azure analysis services using an Azure c# .net6 function app. I am getting that the Specified method is not supported when connecting to analysis services. my connection string looks correct. my server name is correct and the initial catalog is the model's name. I was using the following blog as a guide and it looks like I am doing the connection string correctly https://endjin.com/blog/2020/02/azure-analysis-services-how-to-open-a-connection-from-net
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using Microsoft.AnalysisServices.Tabular;
using Azure.Identity;
using System.Threading.Tasks;
namespace refreshModel
{
public static class AnalysisServicesRefreshFunction
{
[FunctionName("AnalysisServicesRefreshFunction")]
public static async Task Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
// Retrieve environment variables
string env = Environment.GetEnvironmentVariable("ENV");
if (string.IsNullOrEmpty(env))
{
throw new InvalidOperationException("ENV environment variable is not found.");
}
// Analysis services details
string serverNamePrefix = "serverNamePrefix";
string serverName = serverNamePrefix + env;
string aasDatabaseName = "aasDatabaseName";
var credential = new DefaultAzureCredential();
var token = await credential.GetTokenAsync(new Azure.Core.TokenRequestContext(new[] { "https://uksouth.asazure.windows.net" }));
var connectionString = $"Provider=MSOLAP;Data Source=asazure://uksouth.asazure.windows.net/{serverName}:rw;Initial Catalog={aasDatabaseName};User ID=;Password={token.Token};Persist Security Info=True;Impersonation Level=Impersonate;";
using (var server = new Server())
{
try
{
server.Connect(connectionString);
}
catch (Exception ex)
{
log.LogError($"An error occurred while connecting to the server: {ex.Message}");
throw;
}
try
{
Database database = server.Databases.FindByName(aasDatabaseName);
if (database == null)
{
throw new InvalidOperationException("Azure analysis services database not found.");
}
Model model = database.Model;
if (model == null)
{
throw new InvalidOperationException("Model not found.");
}
// Refresh the model
model.RequestRefresh(RefreshType.Full);
model.SaveChanges();
log.LogInformation("Data model refresh requested successfully.");
}
catch (Exception ex)
{
log.LogError($"An error occurred while refreshing the data model: {ex.Message}");
throw;
}
}
}
}
}
added error log
packages used
<PackageReference Include="Azure.Identity" Version="1.10.4" />
<PackageReference Include="Microsoft.AnalysisServices.NetCore.retail.amd64" Version="19.74.2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
I have added the correct permissions as well. I have a mi in a security group and registered that security group as an admin. I have double-checked and it has correctly added as an admin.
I assume that it has something to do with the connection string where I am passing in the token. don't know if there is an access token argument.
I also posted the same question on Microsoft Q and A
and got the following response from Microsoft agent
"I'm encountering the same issue with the same error on in my Function App using a durable function. Only difference is that I'm using Microsoft.Identity.Client instead of Azure.Identity. Cause according to following site https://www.nuget.org/packages/Microsoft.AnalysisServices.NetCore.retail.amd64#dependencies-body-tab they are dependant. I'm using the latest versions of both dll's but it doesn't make a difference. I'm also getting Specified method is not supported while everything in working fine localy on my laptop. I'll logged at ticket in Azure for support. Can you keep me posted if you would get a solution to this problem. I'll do so as well."
After getting this error created a check to see if the token is empty but it is not so the token is being created. So not really sure why am getting this error.
Update
Tried removing optional params in connection string such as Security Info=True;Impersonation Level=Impersonate but still getting same error. So this is not the reason.
