Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=7.0.0.0, #37271

Closed
Prince269090 opened this issue Jun 28, 2023 · 1 comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@Prince269090
Copy link
Contributor

Prince269090 commented Jun 28, 2023

Library name and version

Microsoft.NET.Sdk.Functions" Version="4.2.0

Describe the bug

I have function app with below packages and files. and i am always getting error during run.

[assembly: FunctionsStartup(typeof(Startup))]
namespace SampleErrors
{
    /// <summary>
    /// A class that inherits from FunctionsStartup and overrides the methods to configure the app and the host for Azure Functions.
    /// </summary>
    public class Startup : FunctionsStartup
    {
        /// <summary>
        /// Configures the app configuration using the given builder.
        /// </summary>
        /// <param name="builder">The functions configuration builder.</param>
        public override void ConfigureAppConfiguration(IFunctionsConfigurationBuilder builder)
        {
        }

        /// <summary>
        /// Configures the host using the given builder.
        /// </summary>
        /// <param name="builder">The functions host builder.</param>
        public override void Configure(IFunctionsHostBuilder builder)
        {
            var configurationBuilder = new ConfigurationBuilder()
                   .SetBasePath(Environment.CurrentDirectory)
                   .AddEnvironmentVariables();

            var location = string.IsNullOrEmpty(Environment.GetEnvironmentVariable(ConfigurationConstants.LOCATION))
               ? string.Empty
               : Environment.GetEnvironmentVariable(ConfigurationConstants.LOCATION);

            var environment =
                string.IsNullOrEmpty(Environment.GetEnvironmentVariable(ConfigurationConstants.ASPNETCORE_ENVIRONMENT))
                    ? ConfigurationConstants.ENVIRONMENT_UAT
                    : Environment.GetEnvironmentVariable(ConfigurationConstants.ASPNETCORE_ENVIRONMENT);

            configurationBuilder.AddJsonFile($"{ConfigurationConstants.APPSETTINGS}.{environment}{location}.json", optional: true, reloadOnChange: true);

#if DEBUG
            configurationBuilder.AddJsonFile($"appsettings.json", optional: true);
#endif

            var configuration = configurationBuilder.Build();
            builder.Services.AddSingleton(configuration);


            builder.Services.AddLogging();
            builder.Services.AddTransient<Function1>();
        }


       
    }
}

Function

 public class Function1
    {
        [FunctionName("Function1")]
        public void Run([ServiceBusTrigger("errorsprocessorqueue", Connection = "ServiceBusConnection", IsSessionsEnabled =true)]string myQueueItem, ILogger log)
        {
            log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
        }
    }

Packages

<ItemGroup>
     <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
     <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.11.0" />
     <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
     <PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="6.0.1" />
     <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
     <PackageReference Include="Microsoft.Azure.ServiceBus" Version="5.2.0" />
     <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
     <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.3" />
     <PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
     <PackageReference Include="System.Drawing.Common" Version="7.0.0" />
 </ItemGroup>

Expected behavior

It should run without issue or error

Actual behavior

Error

[2023-06-28T12:51:16.695Z] A host error has occurred during startup operation 'c107b0b5-9651-48c1-8234-b5668db91149'.
[2023-06-28T12:51:16.700Z] Microsoft.Azure.WebJobs.Script: Error configuring services in an external startup class. SampleErrors: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

Reproduction Steps

Create function app with the files given and when we run its giving issue. its in .net 6

Environment

.net 6
Visual studio 2022
OS : Windows 11

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jun 28, 2023
@jsquire
Copy link
Member

jsquire commented Jun 28, 2023

This issue has been transferred to the repository where the Microsoft.NET.Sdk.Functions library is maintained as #614.

@jsquire jsquire closed this as completed Jun 28, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

2 participants