Azure 函数:无法加载 DLL 'sni.dll' 或其依赖项之一:找不到指定的模块.(0x8007007E) [英] Azure functions: Unable to load DLL 'sni.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)

查看:24
本文介绍了Azure 函数:无法加载 DLL 'sni.dll' 或其依赖项之一:找不到指定的模块.(0x8007007E)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 Azure 门户中运行此 Azure 函数,但由于上述标题错误而失败:

Trying to run this Azure Function in Azure portal but fails with above title error:

    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 发布的,所以不确定如何解决这个问题.非常感谢帮助.

I've added in the AzureSQL database ADO.NET ConnectionString: Google search shows this issue mostly happening for local in regards to System.Data.SqlClient. But the issue I have is at host in azure's portal, i'm not publishing from VS, so not sure how to fix this. Help really appreciated.

如果我也尝试为 Microsoft.Data.SqlClient 更改 System.Data.SqlClient 但无法编译:命名空间Microsoft"中不存在类型或命名空间名称Data"(您是否缺少程序集)参考?)

In case I also tried to change System.Data.SqlClient for Microsoft.Data.SqlClient but can't compile: The type or namespace name 'Data' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

在 Azure cli 中,我可以看到 .net core 是 v 2.2.402,但不确定是否更新到 3.1 会是这个问题吗?我可以在 Windows 10 pc 上更新到 .Net Core 3.1,但 Azure cli 继续显示 .net core 2.2.402.我在 stackoverflow 问题中发布了问题如何更新蔚蓝的环境.

In Azure cli I can see .net core is v 2.2.402 and not sure if updating to 3.1 could this be the issue? I can update to .Net Core 3.1 on windows 10 pc but Azure cli continues to show .net core 2.2.402. I posted question in stackoverflow question how to also update the azure environment.

非常感谢您的帮助,干杯!

Thanks a bunch for your help, cheers!

推荐答案

连接字符串似乎有问题.请检查您是否正在使用类似的东西:

It looks like something is wrong with the connection string. Please check that you are you using something similar to this:

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这个推荐的库有什么问题,需要先添加到解决方案中:

For what concern using Microsoft.Data.SqlClient, which is the recommended library, you need to add it to the solution first:

dotnet add package Microsoft.Net.SqlClient

这篇关于Azure 函数:无法加载 DLL 'sni.dll' 或其依赖项之一:找不到指定的模块.(0x8007007E)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆