You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Function App连接Analysis Services时遇‘指定方法不支持’错误

Azure Functions (.NET 6) 连接Azure Analysis Services时出现"Specified method is not supported"错误

我在使用Azure C# .NET 6 Function App刷新Azure Analysis Services数据模型时,连接Analysis Services环节抛出**"Specified method is not supported"**错误。已确认连接字符串、服务器名称、初始目录均正确,且参考相关技术博客完成配置。

代码实现

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;
                }
            }
        }
    }
}

使用的NuGet包

<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" />

已完成的排查动作

  • 已添加错误日志,确认错误发生在server.Connect(connectionString)环节
  • 权限配置验证无误:将Function App托管标识加入安全组,该安全组已注册为Azure Analysis Services管理员,双重验证配置正常
  • 已验证DefaultAzureCredential生成的token非空,排除令牌生成问题
  • 曾怀疑连接字符串可选参数导致问题,移除Persist Security Info=True;Impersonation Level=Impersonate后,错误依旧
  • 在官方技术问答平台反馈问题后,得到工作人员回复:其他用户使用Durable Function时也遇到相同现象——本地运行正常,部署到Azure后报错,该用户已提交Azure支持工单

内容的提问来源于stack exchange,提问作者Muhammad Pathan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 08:45:05