Azure函数:无法加载DLL';sni.dll';或其依赖项之一:找不到指定的模块。(0x8007007E)

Azure函数:无法加载DLL';sni.dll';或其依赖项之一:找不到指定的模块。(0x8007007E),azure,.net-core,azure-sql-database,azure-functions,Azure,.net Core,Azure Sql Database,Azure Functions,尝试在Azure门户中运行此Azure功能,但失败,出现上述标题错误: using System; using System.IO; using System.Net; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.WebJobs; using Microsoft.AspNetCore.Http; using M

尝试在Azure门户中运行此Azure功能,但失败,出现上述标题错误:

    using System;
    using System.IO;
    using System.Net;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.Azure.WebJobs;
    using Microsoft.AspNetCore.Http;
    using Microsoft.Extensions.Logging;
    using Microsoft.Extensions.Primitives;
    using Newtonsoft.Json;
    using System.Data.SqlClient;

    public static string Run(HttpRequest req, ILogger log)
    {
        string name="dbconn";
        string conStr = System.Environment.GetEnvironmentVariable(name, EnvironmentVariableTarget.Process);

        if (string.IsNullOrEmpty(conStr)) // Azure Functions App Service naming convention
            conStr = System.Environment.GetEnvironmentVariable($"SQLCONNSTR_{name}", EnvironmentVariableTarget.Process);
        using (SqlConnection conn = new SqlConnection(conStr))
            {
                conn.Open();

            }
        return conStr;
我在AzureSQL数据库ADO.NET ConnectionString中添加了: 谷歌搜索显示,这个问题主要发生在本地的System.Data.SqlClient上。但我遇到的问题是在azure门户的主机上,我不是从VS发布的,所以不知道如何解决这个问题。我真的很感激你的帮助

如果我还试图更改Microsoft.Data.SqlClient的System.Data.SqlClient,但无法编译:命名空间“Microsoft”中不存在类型或命名空间名称“Data”(是否缺少程序集引用?)

在Azure cli中,我可以看到.net核心是v2.2.402,不确定是否更新到3.1这可能是问题所在吗?我可以在windows 10 pc上更新到.Net Core 3.1,但Azure cli继续显示.Net Core 2.2.402。我发布了关于如何更新azure环境的问题


谢谢你的帮助,干杯

连接字符串似乎有问题。请检查您是否正在使用类似以下内容:

Server=tcp:{your_server}.database.windows.net,1433;Initial Catalog={your_database};Persist Security Info=False;User ID={your_user};Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
对于使用Microsoft.Data.SqlClient(推荐的库)的问题,您需要首先将其添加到解决方案中:

dotnet add package Microsoft.Net.SqlClient

顺便说一句,这里有一个Azure SQL和Azure函数的完整工作示例:谢谢@mauridb,是的,连接字符串符合上面显示的模式。关于dotnet命令,我在Azure cli中执行,在
/home/sergio/
中找不到任何项目。然后我尝试了kudu的函数CMD D:\home\site\wwwroot>cd FunctionName和D:\home\site\wwwroot,但get仍然无法在“path”中找到任何项目。我可能做错了什么?我尝试了您发布的git示例,直接部署到门户会出现错误当前的.NET SDK不支持针对.NET Core 3.1。以.NET Core 2.2或更低版本为目标,或使用支持.NET Core 3.1的.NET SDK版本。[D:\home\site\repository\Autoscaler.csproj]。然而,我的dotnet--info显示了.NET核心SDK(反映了任何全局.json):版本:2.2.402。只能从VS运行?非常感谢@mauridb,我已经使用了您的项目设置,现在可以避免此错误消息。我还发现您所链接的项目对sql例程非常有帮助:)确保在Azure函数应用程序设置中有“AzureSQLConnection”您的函数是从vs部署的吗?