0

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

enter image description here

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

https://learn.microsoft.com/en-us/answers/questions/1527630/function-app-not-connecting-to-analysis-services-s

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.

1 Answer 1

0

Did you check the AS firewall? I had the same error and it just meant that the IP address of the calling entity was not present in the AS firewall as an allowed address.

The error message is absolutely terrible, and earlier versions of the libraries did way better and actually stated that the IP address was not allowed. But we cannot expect good messages from a multi billion company, ofc.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.