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

Cosmos trigger on Azure Functions v4 (.net 6) fails - cannot resolve SystemConfiguration.ConfigurationManager #750

Closed
AdrianPell opened this issue Oct 19, 2021 · 7 comments

Comments

@AdrianPell
Copy link

I have a Cosmos trigger on Azure Functions v4 which cannot register the function because of a failure to resolve System.Configuration.ConfigurationManager version 4.0.3.0 (aka 4.7.0)

Repro steps

Create a function project - .net6 preview, functions v4 - with the following function:

        [FunctionName("Function1")]
        public async Task Run([CosmosDBTrigger(
            databaseName: "Stats",
            containerName: "RawData",
            Connection = "DefaultConnection")]IReadOnlyList<object> input, ILogger log)
        {
            if (input != null && input.Count > 0)
            {
                log.LogInformation("Documents modified " + input.Count);
            }

            await Task.CompletedTask;
        }

local.settings.json is as follows:

{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",

    "DefaultConnection": "___REDACTED___"
  }
}

Expected behavior

Function should run ...

Actual behavior

Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1'. Microsoft.Azure.WebJobs.Extensions.CosmosDB: Cannot create container information for RawData in database Stats with lease leases in database Stats : 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. Microsoft.Azure.Cosmos.Client: 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.

Known workarounds

None yet

  • Package version
    Microsoft.Azure.WebJobs.Extensions.CosmosDB - 4.0.0-preview2
    Microsoft.Azure.Cosmos - 3.22.0
@ghost ghost added the Needs: Triage 🔍 label Oct 19, 2021
@v-bbalaiagar v-bbalaiagar self-assigned this Oct 20, 2021
@ealsur
Copy link
Member

ealsur commented Oct 20, 2021

Please see Azure/azure-cosmos-dotnet-v3#2798 (comment) this seems apparently some issue with System.Configuration on NET 6 but only when running on Functions (other users seem to have no issue outside of Functions). I don't know what is particular about Functions runtime though, probably something Functions team can chip in.

@AdrianPell
Copy link
Author

Yep that's the same issue I think and it appears to be Functions specific.

@cgillum is this likely to be a Functions issue?

@cgillum
Copy link

cgillum commented Oct 20, 2021

Seems likely to me to be Functions-specific. Adding @brettsam for awareness.

@brettsam
Copy link
Member

Try using 4.0.0 of Microsoft.NET.Sdk.Functions -- that should fix it. https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions/4.0.0

@AdrianPell
Copy link
Author

Thanks @brettsam . That did indeed, fix it! Onward to the release, then :-)

@ghost ghost removed the Needs: Triage 🔍 label Oct 20, 2021
@v-bbalaiagar v-bbalaiagar removed their assignment Oct 21, 2021
@pongba
Copy link

pongba commented Apr 6, 2022

Try using 4.0.0 of Microsoft.NET.Sdk.Functions -- that should fix it. https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions/4.0.0

Can you elaborate details regarding how this if this in 4.0.0? I have a similar issue here with C++/CLI enabled native-managed hybrid service, in which a user C# script (.csx) is executed inside a native entry service. Because GetEntryAssembly returns null, the SystemConfiguration.ConfigurationManager throws PlatformNotSupportedException. Same .csx worked under .NET Framework previously, however.

I'd like to know how Azure Functions fixed this so I can apply the same fix to my case.

@brettsam
Copy link
Member

brettsam commented Apr 6, 2022

System.Configuration.ConfigurationManager.dll needs to be somewhere that the app can load it. During the Functions build, we run a "cleanup" that deletes files that will already be present in Azure so you can save space in your deployment. We had a bug between the 4.0.0-preview and 4.0.0 of the Functions SDK where we'd not updated that list of files to delete, so it was deleting System.Configuration.ConfigurationManager.dll, even though it didn't exist in the Functions Azure deployment.

This list of files to delete is maintained as an embedded resource in Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.dll.

I don't understand your scenario, but the solution here was "make sure that file is deployed with the app"....

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

No branches or pull requests

6 participants