简体   繁体   English

Azure:函数主机未运行

[英]Azure: Function host is not running

I have a Function App in azure and when I hit the URL of the function app it says "Function host is not running."我有一个天蓝色的函数应用程序,当我点击函数应用程序的 URL 时,它显示“函数主机未运行”。 I have checked the log also in the app insights or in the Azure portal's function app service, it shows the following error message in the function app.我还在应用洞察力或 Azure 门户的函数应用服务中检查了日志,它在函数应用中显示以下错误消息。

Note: My pipeline's Build & Releases got succeeded, so I am not sure where to check and what is the solution for this.注意:我的管道的构建和发布成功了,所以我不确定在哪里检查以及解决方案是什么。 I tried with a new function app but still no luck.我尝试了一个新的功能应用程序,但仍然没有运气。

在此处输入图像描述

My Startup.cs file to understand How I have referred the config values,我的 Startup.cs 文件以了解我如何引用配置值,

 public override void Configure(IFunctionsHostBuilder builder)
    {
        //var connectionString = Environment.GetEnvironmentVariable("ConnectionStrings:DBConnection");

        var serviceProvider = builder.Services.BuildServiceProvider();
        _configuration = serviceProvider.GetRequiredService<IConfiguration>();
        var appSettingsSection = _configuration.GetSection("AppSettings");
        builder.Services.Configure<AppSettings>(appSettingsSection);
        var appSettings = appSettingsSection.Get<AppSettings>();
        RuntimeConfig.appsettings = appSettings;

        var ConnectionString = RuntimeConfig.appsettings.AppDBConnection;
        ///builder.Services.AddDbContext<ShardingDbContext>(options => options.UseSqlServer(ConnectionString), ServiceLifetime.Transient);
        //builder.Services.AddScoped<ITestService, TestService>();


    }

    public override void ConfigureAppConfiguration(IFunctionsConfigurationBuilder builder)
    {
        FunctionsHostBuilderContext context = builder.GetContext();

        builder.ConfigurationBuilder
            .AddJsonFile(Path.Combine(context.ApplicationRootPath, "local.settings.json"), optional: true, reloadOnChange: false)
            .AddJsonFile(Path.Combine(context.ApplicationRootPath, $"{context.EnvironmentName}.settings.json"), optional: true, reloadOnChange: false)
            .AddEnvironmentVariables();
    }

I am taking the config values as IConfiguration, it works for my local but don't know how to do the same in the server.我将配置值作为 IConfiguration,它适用于我的本地但不知道如何在服务器中执行相同操作。

while deploying your Function app it neither upload local.settings.json to Azure or nor makes modification on Application Settings based on local.settings.json file.在部署您的函数应用程序时,它既不会将local.settings.json上传到 Azure,也不会根据local.settings.json文件对应用程序设置进行修改。

The Key-value pair related to EIA present in local.settings.json , add the same key-value pair in Azure Function App Configuration > Application Settings in the Portal. local.settings.json中存在的与EIA相关的键值对,在门户中的 Azure Function App 配置 > 应用程序设置中添加相同的键值对。

For that we have to manually update the App Settings in portal or if you are using Visual studio , we can update using VS publish panel .为此,我们必须手动更新门户中的应用程序设置,或者如果您使用的是Visual Studio ,我们可以使用VS 发布面板进行更新。

Add Application Settings using Portal使用门户添加应用程序设置

  • Azure Portal -> Your Azure Function -> Configuration Panel -> Application Settings/Connection Strings (Add your custom configuration) Azure 门户 -> 您的 Azure 功能 -> 配置面板 -> 应用程序设置/连接字符串(添加您的自定义配置)在此处输入图像描述

Add Application Settings using Visual Studio Publish panel使用 Visual Studio 发布面板添加应用程序设置

  • While publishing your azure function Add your Application settings.在发布您的天蓝色功能时添加您的应用程序设置。

  • In a hosting panel right corner click ( ... ).在托管面板右上角单击 ( ... )。

  • Add your app Settings in Manage Azure App Service Settings.在管理 Azure 应用服务设置中添加应用设置。在此处输入图像描述

  • Add your settings like below添加您的设置,如下所示在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM