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

'System.Configuration.ConfigurationManager, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. #2798

Closed
raedg2000 opened this issue Oct 17, 2021 · 7 comments

Comments

@raedg2000
Copy link

Running a deployed Azure Function on Azure that connects to cosmos db using V4 gives an error.
Even when trying version 3.x it gives the same error.

In this function, I connect to a cosmosdb (SQL API)

Azure Function Project:

net6.0
v4




Once I try to open a connect to cosmos db in the deployed azure function:

CosmosClient cosmosClient = new CosmosClient(cosmosDbConnectionString);

this error is captured.

'System.Configuration.ConfigurationManager, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

When I remove the code that is related to cosmos db , the deployed azure function runs without errors.
Cosmos Db library depends on the System.Configuration.ConfigurationManager version 4.*

regards,
Raed

@ealsur
Copy link
Member

ealsur commented Oct 18, 2021

@raedg2000 Can you try with V3 SDK? Why are you using V4?

@spDhairya
Copy link

I have tried with V3 SDK as well but i see exact same issue.

@spDhairya
Copy link

I was able to repro exactly same issue. I have CosmosClient middleware that is being used for both MVC web API and Function App. Today I upgraded both my API and function App from .netcore 3.1 to .net 6 [Tried with .net 5 as well] and I can see API is able to load and execute Cosmos Client fine without any issue. However Azure Function (both on runtime v3 and runtime v4) fails to load cosmos client with error –
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.'

at Microsoft.Azure.Cosmos.DocumentClient.Initialize(Uri serviceEndpoint, ConnectionPolicy connectionPolicy, Nullable1 desiredConsistencyLevel, HttpMessageHandler handler, ISessionContainer sessionContainer, Nullable1 enableCpuMonitor, IStoreClientFactory storeClientFactory, TokenCredential tokenCredential)
at Microsoft.Azure.Cosmos.DocumentClient..ctor(Uri serviceEndpoint, AuthorizationTokenProvider cosmosAuthorization, EventHandler1 sendingRequestEventArgs, ConnectionPolicy connectionPolicy, Nullable1 desiredConsistencyLevel, JsonSerializerSettings serializerSettings, ApiType apitype, EventHandler1 receivedResponseEventArgs, HttpMessageHandler handler, ISessionContainer sessionContainer, Nullable1 enableCpuMonitor, Func`2 transportClientHandlerFactory, IStoreClientFactory storeClientFactory)
at Microsoft.Azure.Cosmos.ClientContextCore.Create(CosmosClient cosmosClient, CosmosClientOptions clientOptions)
at Microsoft.Azure.Cosmos.CosmosClient..ctor(String accountEndpoint, AuthorizationTokenProvider authorizationTokenProvider, CosmosClientOptions clientOptions)
at Microsoft.Azure.Cosmos.CosmosClient..ctor(String accountEndpoint, String authKeyOrResourceToken, CosmosClientOptions clientOptions)
at [[Application Code Redacted]]..ctor([[Application Code Redacted]]) [[Redacted]]
at Microsoft.Azure.Functions.Extensions.DependencyInjection.FunctionsStartup.Configure(WebJobsBuilderContext context, IWebJobsBuilder builder)
at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.ConfigureStartup(IWebJobsStartup startup, WebJobsBuilderContext context, IWebJobsBuilder builder) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs:line 162
at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.ConfigureAndLogUserConfiguredServices(IWebJobsStartup startup, WebJobsBuilderContext context, IWebJobsBuilder builder, ILoggerFactory loggerFactory) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs:line 130
at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.UseWebJobsStartup(IWebJobsBuilder builder, Type startupType, WebJobsBuilderContext context, ILoggerFactory loggerFactory) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs:line 115
at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.UseExternalStartup(IWebJobsBuilder builder, IWebJobsStartupTypeLocator startupTypeLocator, WebJobsBuilderContext context, ILoggerFactory loggerFactory) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs:line 213
at Microsoft.Azure.WebJobs.Script.ScriptHostBuilderExtensions.<>c__DisplayClass7_0.b__1(HostBuilderContext context, IWebJobsBuilder webJobsBuilder) in D:\a\1\s\src\WebJobs.Script\ScriptHostBuilderExtensions.cs:line 211
at Microsoft.Extensions.Hosting.WebJobsHostBuilderExtensions.<>c__DisplayClass5_0.b__1(HostBuilderContext context, IServiceCollection services) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsHostBuilderExtensions.cs:line 54
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at Microsoft.Azure.WebJobs.Script.WebHost.DefaultScriptHostBuilder.BuildHost(Boolean skipHostStartup, Boolean skipHostConfigurationParsing) in D:\a\1\s\src\WebJobs.Script.WebHost\DefaultScriptHostBuilder.cs:line 59
at Microsoft.Azure.WebJobs.Script.WebHost.WebJobsScriptHostService.BuildHost(Boolean skipHostStartup, Boolean skipHostJsonConfiguration) in D:\a\1\s\src\WebJobs.Script.WebHost\WebJobsScriptHostService.cs:line 553
at Microsoft.Azure.WebJobs.Script.WebHost.WebJobsScriptHostService.d__51.MoveNext() in D:\a\1\s\src\WebJobs.Script.WebHost\WebJobsScriptHostService.cs:line 250

@raedg2000
Copy link
Author

I have tried using V3 SDK but got the same error. The problem appeared when we started using .Net 6 RC 2 and the new Azure Function Runtime V4.
Once we down graded to .Net 3.1 and used the Azure Runtime V3 the error disappeared. The reason, I have posted it here because the error appears when calling Cosmos db. I have downloaded the Cosmos Db project and referenced it in the Azure function project after upgrading it to .net 6.0 and using the latest version of System.Configuration.ConfigurationManager. I received a similar error but this time with the new Version of System.Configuration.ConfigurationManager . I have added the Nuget Package to the Azure Function itself, still did not work. I think the issue is with the new Azure functions runtime - it is not loading the library.

@ealsur
Copy link
Member

ealsur commented Oct 20, 2021

@ealsur
Copy link
Member

ealsur commented Oct 20, 2021

Please see Azure/azure-webjobs-sdk-extensions#750 (comment) for the Functions fix.

@mohamedeshiba
Copy link

I had the same problem when I tried to connect to CosmosDb from a time triggered Azure Function.
Here what I did to solve the problem
1- downgraded the projecto to netcoreapp3.1
2- Used the Azure Function V3
3- used Microsoft.NET.Sdk.Functions version 3.1.1(any version 3)
4- Added <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> in the property Group tag in the .csproj

It worked for me. Hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants