C# 连接到Azure功能中的Azure Analysis Services

C# 连接到Azure功能中的Azure Analysis Services,c#,azure,azure-functions,C#,Azure,Azure Functions,我在几个示例代码的基础上构建了一个C#脚本,允许刷新托管在SSAS服务器上的数据库,但我收到了一个错误代码。 知道如何修复错误吗 C#计时器触发函数异常:System.NullReferenceException:对象引用未设置为对象的实例。 提交时#0.在D:\home\site\wwwroot\TimerTrigger1\Run.csx:第14行中运行(TimerInfo myTimer,TraceWriter log) 您是对的,连接字符串似乎为空。 因此,我通过添加初始目录(我的连接字符

我在几个示例代码的基础上构建了一个C#脚本,允许刷新托管在SSAS服务器上的数据库,但我收到了一个错误代码。 知道如何修复错误吗

C#计时器触发函数异常:System.NullReferenceException:对象引用未设置为对象的实例。 提交时#0.在D:\home\site\wwwroot\TimerTrigger1\Run.csx:第14行中运行(TimerInfo myTimer,TraceWriter log)


您是对的,连接字符串似乎为空。 因此,我通过添加初始目录(我的连接字符串不包含此变量)来更新它

为了绕过这个问题,我把我的
var connStr=ConfigurationManager.ConnectionString[“ConnectStringBIDEV01”]。ConnectionString

现在我收到以下消息。。。我怀疑这是一个进步,但如何解决呢

C# Timer trigger function exception: System.TypeLoadException: Could not load type 'System.Security.Principal.WindowsImpersonationContext' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
   at Microsoft.AnalysisServices.IdentityResolver.Dispose()
   at Microsoft.AnalysisServices.XmlaClient.Connect(ConnectionInfo connectionInfo, Boolean beginSession)
   at Microsoft.AnalysisServices.Core.Server.Connect(String connectionString, String sessionId, ObjectExpansion expansionType)
   at Submission#0.Run(TimerInfo myTimer, TraceWriter log) in D:\home\site\wwwroot\TimerTrigger1\run.csx:line 16

这两个问题
无法加载type
ConfigurationManager.ConnectionStrings get null
都是由于

v1函数以完整的.NET框架为目标,v2在.NET核心环境上运行。您可能已经创建了v2函数(默认情况下),其中Analysis Services SDK(取决于.NET Framework)不起作用,并且不支持ConfigurationManager

因此,解决方案很简单,删除现有函数并将函数运行时版本更改为~1(在门户中,平台功能>函数应用程序设置>),然后创建v1函数


之后,我们可能会看到一些关于
无法找到程序集的警告,请忽略它们,因为我们可以成功连接到AnalysisServices。如果遇到错误,则需要内部网关来访问数据源。请为服务器安装统一网关
,请按照说明安装。

您可以编辑您的帖子并放置所有异常(如堆栈跟踪)吗?是否检查var connStr=ConfigurationManager.ConnectionString[“ConnectStringBIDEV01”]。ConnectionString;不为空?您正在编辑您的帖子,但没有编辑异常并添加堆栈跟踪必须确认该解决方案是否有效,如果它确实有用,您是否可以接受它作为答案?具有相同的mscorlib问题,并且谷歌在解决方案上并不友好。有人用V2和net core连接到azure analysis services解决过这个问题吗?
var connStr = "Provider=MSOLAP;Data Source=asazure://northeurope.asazure.windows.net/xxxxxxxx;Initial Catalog=xxxxxxx;User ID=xxxxxx;Password=xxxxxx";
C# Timer trigger function exception: System.TypeLoadException: Could not load type 'System.Security.Principal.WindowsImpersonationContext' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
   at Microsoft.AnalysisServices.IdentityResolver.Dispose()
   at Microsoft.AnalysisServices.XmlaClient.Connect(ConnectionInfo connectionInfo, Boolean beginSession)
   at Microsoft.AnalysisServices.Core.Server.Connect(String connectionString, String sessionId, ObjectExpansion expansionType)
   at Submission#0.Run(TimerInfo myTimer, TraceWriter log) in D:\home\site\wwwroot\TimerTrigger1\run.csx:line 16