简体   繁体   English

IApplicationBuilder 不包含 UseAzureAppConfiguration 的定义

[英]IApplicationBuilder does not contain a definition for UseAzureAppConfiguration

I've been trying to implement feature managament in my Blazor app following this and that but for some reason my program refuses to accept "UseAzureAppConfiguration" even though I should have the proper usings and packages.我一直在努力实现的功能managament在我Blazor应用下面这个那个,但由于某种原因,我的程序不服“UseAzureAppConfiguration”即使我应该有适当的usings和包。

This is my Startup.cs:这是我的 Startup.cs:

using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.UI;
using Microsoft.FeatureManagement;

namespace OreNoAppu
{
    public class Startup
    {
        public IConfiguration Configuration { get; }

        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
                .AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd"));
            services.AddControllersWithViews().AddMicrosoftIdentityUI();

            // By default, all incoming requests will be authorized according to the default policy
            services.AddAuthorization(options => options.FallbackPolicy = options.DefaultPolicy);

            services.AddRazorPages();
            services.AddServerSideBlazor().AddMicrosoftIdentityConsentHandler();
            services.AddFeatureManagement();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days.You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();
            app.UseAzureAppConfiguration();     // "Does not contain definition" error.

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/_Host");
            });
        }
    }
}

These are my nugets:这些是我的要点:

  <ItemGroup>
    <PackageReference Include="Azure.Identity" Version="1.4.1" />
    <PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.2.0" />
    <PackageReference Include="BlazorPro.Spinkit" Version="1.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.4" NoWarn="NU1605" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.4" NoWarn="NU1605" />
    <PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="4.5.0" />
    <PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="2.4.0" />
    <PackageReference Include="Microsoft.Identity.Web" Version="1.1.0" />
    <PackageReference Include="Microsoft.Identity.Web.UI" Version="1.1.0" />
  </ItemGroup>

Anyone have any idea why it can't find the method?任何人都知道为什么它找不到方法?

Azure App Configuration helps to manage application settings and control their access centrally. Azure 应用程序配置有助于管理应用程序设置并集中控制其访问。 It's built on the simple concept of key-value pairs, and this service provides manageability, availability, and ease-of-use.它建立在简单的键值对概念之上,该服务提供了可管理性、可用性和易用性。

To solve the problem you are facing please check if you are using the right library and also check if you are having the following NuGet packages from Microsoft to work with an Azure App Configuration resource and the ability to use Feature Flags in the project .要解决您面临的问题,请检查您是否使用了正确的库,并检查您是否拥有以下来自 Microsoft 的 NuGet 包来处理 Azure 应用程序配置资源以及​​在项目中使用功能标志的能力

Microsoft.Azure.AppConfiguration.AspNetCore Microsoft.Extensions.Configuration.AzureAppConfiguration Microsoft.FeatureManagement Microsoft.Azure.AppConfiguration.AspNetCore Microsoft.Extensions.Configuration.AzureAppConfiguration Microsoft.FeatureManagement

As you have added FeatureManagement by using statement in Startup.cs and inside of ConfigureServices (...) added the ability to use it.由于您在Startup.csConfigureServices (...) 中通过 using 语句添加了FeatureManagement ,因此添加了使用它的能力。 Check if have modified the Program.cs and replaced the creation of default host builder with one that uses Azure App Configuration as shown below.检查是否已修改Program.cs并将默认主机生成器的创建替换为使用 Azure 应用程序配置的生成器,如下所示。

public  static  IHostBuilder CreateHostBuilder(string[] args) =>
  Host.CreateDefaultBuilder(args)
    .ConfigureWebHostDefaults(webBuilder =>
     webBuilder.ConfigureAppConfiguration((hostingContext, config) =>
     {
        var  settings = config.Build(); 
        config.AddAzureAppConfiguration(options => { 
            options.Connect(Environment.GetEnvironmentVariable("ConnectionString")) 
                    .ConfigureRefresh(refresh => { 
                            refresh.Register("Settings:Sentinel", refreshAll: true).SetCacheExpiration(new  TimeSpan(0, 1, 0)); 
                         }) 
                    .UseFeatureFlags(); 
        }); 
      }) 
      .UseStartup<Startup>());

Check this How to Add Azure App Configuration and Feature Flags into Blazor in .Net 5 document for detailed step by step explanation with example.检查此如何将 Azure 应用程序配置和功能标志添加到 .Net 5文档中的Blazor 以获取详细的分步说明和示例。

For more information also check the following documentations :有关更多信息,请查看以下文档:

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

相关问题 IApplicationBuilder 不包含 UseIdentity 的定义 - IApplicationBuilder does not contain a definition for UseIdentity “IApplicationBuilder”不包含“MapAzureSignalR”的定义 - 'IApplicationBuilder' does not contain a definition for 'MapAzureSignalR' “IApplicationBuilder”不包含“HttpContext”的定义 - 'IApplicationBuilder' does not contain a definition for 'HttpContext' IApplicationbuilder 不包含 CreatePerOwinContext 的定义 - IApplicationbuilder does not contain definition for CreatePerOwinContext “IApplicationBuilder”不包含“UseWebAssemblyDebugging”的定义 - 'IApplicationBuilder' does not contain a definition for 'UseWebAssemblyDebugging' “IServiceCollection”不包含“AddMvc”的定义,“IApplicationBuilder”不包含“UseStaticFiles”的定义, - 'IServiceCollection' does not contain a definition for 'AddMvc', 'IApplicationBuilder' does not contain a definition for 'UseStaticFiles', 不包含“ ToPagedList”的定义 - Does not contain a definition for 'ToPagedList' “对象”不包含定义 - 'object' does not contain a definition IGrouping不包含以下定义 - IGrouping does not contain a definition for 不包含GroupBy的定义 - Does Not Contain Definition for GroupBy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM