Closed gauraviitr closed 6 years ago
We're in the process of rolling out a v2 update that has some breaking changes, which is discussed here: https://github.com/Azure/app-service-announcements/issues/94
Theres a good chance that this is what you're hitting. Check the version of your function app and see if matches the details in the announcement. If so, follow the steps. Let us know how it goes.
cc @brettsam
That fixed it but now this shows up:
ScriptHost initialization failed
[3/29/2018 12:05:48 AM] Microsoft.Azure.WebJobs.Extensions.CosmosDB: Method not found: 'Void Microsoft.Azure.WebJobs.Host.Config.FluentBindingRule1.AddValidator(System.Action
2<!0,System.Type>)'.
Listening on http://localhost:7071/
Hit CTRL-C to exit...
Object reference not set to an instance of an object.
Hrm, so you're getting this locally? Unfortunately things get even more complicated in this case because it depends on the version of the azure-functions-core-tools that is being used when you run.
@ahmelsayed is there a release in the works of core-tools with runtime 2.0.11651 or later?
Yeah thats the error locally. On functions, I'm just not able to get data out of my cosmos database into the function via binding having tried everything. Struggling quite a bit - would someone be able to help.
@paulbatum looks like this error is similar to the one at https://github.com/Azure/app-service-announcements-discussions/issues/41
I'm using functions v2.x runtime .Net Core 2.0
When trying to use input CosmosDb binding I receive this exception:
System.MissingMethodException: 'Method not found: 'Void Microsoft.Azure.WebJobs.Host.Config.FluentBindingRule1.AddValidator(System.Action
2<!0,System.Type>)'.'
After publishing to the cloud I got the dead function, that is impossible to run.
@GvozdevDA -- are you using the latest nuget packages when you build locally? See here for more information, including which nugets you should be referencing now: https://github.com/Azure/app-service-announcements/issues/94#issuecomment-376647094.
@brettsam I reference Microsoft.NET.Sdk.Functions 1.0.13
and don't have a reference on Microsoft.Azure.WebJobs.Extensions.DurableTask
since I don't use durable functions. I'll try to add this reference but don't think it is an issue here.
What about Microsoft.Azure.WebJobs.Extensions.CosmosDB
?
... sent that too soon. You'll likely need to do the steps under "To fix a function app written locally using azure-functions-core-tools (including VS Code)"
@brettsam I have exactly the same version of 'Microsoft.Azure.WebJobs.Extensions.CosmosDB' as recommended.
@brettsam Oh, thanks, I'll try and give you the feedback.
Experiencing exactly the same problems as written above.
Installing the Azure Functions CLI and issuing the mentioned command leads to the following output:
func extensions sync
Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
Microsoft (R) Build Engine version 15.6.82.30579 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restoring packages for C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\TestDataArasIntegration\functions-extensions\extensions.csproj...
Generating MSBuild file C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\TestDataArasIntegration\functions-extensions\obj\extensions.csproj.nuget.g.props.
Generating MSBuild file C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\TestDataArasIntegration\functions-extensions\obj\extensions.csproj.nuget.g.targets.
Restore completed in 184.04 ms for C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\TestDataArasIntegration\functions-extensions\extensions.csproj.
extensions -> C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\TestDataArasIntegration\bin\extensions.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:05.58
The operation adds an extensions.csproj file to the solution.
After this operation, the Visual Studio 2017 build fails:
Publish Started
CosmosDbWrapper -> C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\CosmosDbWrapper\bin\Release\netstandard2.0\CosmosDbWrapper.dll
TestDataModels -> C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\TestDataModels\bin\Release\netstandard2.0\TestDataModels.dll
obj\Release\netstandard2.0\TestDataArasIntegration.AssemblyInfo.cs(14,12): error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute [C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\TestDataArasIntegration\TestDataArasIntegration.csproj]
obj\Release\netstandard2.0\TestDataArasIntegration.AssemblyInfo.cs(15,12): error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute [C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\TestDataArasIntegration\TestDataArasIntegration.csproj]
obj\Release\netstandard2.0\TestDataArasIntegration.AssemblyInfo.cs(16,12): error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute [C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\TestDataArasIntegration\TestDataArasIntegration.csproj]
obj\Release\netstandard2.0\TestDataArasIntegration.AssemblyInfo.cs(17,12): error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute [C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\TestDataArasIntegration\TestDataArasIntegration.csproj]
obj\Release\netstandard2.0\TestDataArasIntegration.AssemblyInfo.cs(18,12): error CS0579: Duplicate 'System.Reflection.AssemblyProductAttribute' attribute [C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\TestDataArasIntegration\TestDataArasIntegration.csproj]
obj\Release\netstandard2.0\TestDataArasIntegration.AssemblyInfo.cs(19,12): error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute [C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\TestDataArasIntegration\TestDataArasIntegration.csproj]
obj\Release\netstandard2.0\TestDataArasIntegration.AssemblyInfo.cs(20,12): error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute [C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\TestDataArasIntegration\TestDataArasIntegration.csproj]
Publishing via the integrated tools becomes impossible...
Any suggestions from here?
@brettsam tried all possible manipulations with NuGet packages, still having an exception in JobHostConfigurationExtensions.cs
at private static void InvokeExtensionConfigProviders(ExtensionConfigContext context)
Here is my StackTrace:
" at Microsoft.Azure.WebJobs.Extensions.CosmosDB.CosmosDBConfiguration.Initialize(ExtensionConfigContext context)\r\n
at Microsoft.Azure.WebJobs.Host.Executors.JobHostConfigurationExtensions.InvokeExtensionConfigProviders(ExtensionConfigContext context) in C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\JobHostConfigurationExtensions.cs:line 410\r\n
at Microsoft.Azure.WebJobs.Host.Executors.JobHostConfigurationExtensions.CreateStaticServices(JobHostConfiguration config) in C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\JobHostConfigurationExtensions.cs:line 110\r\n
at Microsoft.Azure.WebJobs.JobHost.InitializeServices() in C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\JobHost.cs:line 472\r\n
at Microsoft.Azure.WebJobs.JobHost.get_Services() in C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\JobHost.cs:line 484\r\n
at Microsoft.Azure.WebJobs.Script.Utility.CreateMetadataProvider(JobHost host) in C:\\azure-webjobs-sdk-script\\src\\WebJobs.Script\\Utility.cs:line 375\r\n
at Microsoft.Azure.WebJobs.Script.ScriptHost.LoadCustomExtensions() in C:\\azure-webjobs-sdk-script\\src\\WebJobs.Script\\Host\\ScriptHost.cs:line 723\r\n
at Microsoft.Azure.WebJobs.Script.ScriptHost.Initialize() in C:\\azure-webjobs-sdk-script\\src\\WebJobs.Script\\Host\\ScriptHost.cs:line 540\r\n
at Microsoft.Azure.WebJobs.Script.ScriptHost.Create(IScriptHostEnvironment environment, IScriptEventManager eventManager, ScriptHostConfiguration scriptConfig, ScriptSettingsManager settingsManager, ILoggerFactoryBuilder loggerFactoryBuilder, ProxyClientExecutor proxyClient) in C:\\azure-webjobs-sdk-script\\src\\WebJobs.Script\\Host\\ScriptHost.cs:line 996"
@GvozdevDA -- Is this error coming when you hit F5? Or when you deploy? Are you using VS?
@Saphirim -- Do you see those attributes (AssemblyCompanyAttribute
, etc) in multiple places? Are they declared in the AssemblyInfo.cs
file as well as the project's csproj file? You may be hitting some variation of this: https://github.com/dotnet/cli/issues/4710
@brettsam I am using Visual Studio 2017 last update. This error comes after running app locally (pressing F5). When I publish this Function app and hit "Run" at the Azure portal, I got a grayed screen with red "Cancel" button for a second and afterward logs with messages like:
Welcome, you are now connected to log-streaming service.
No new trace in the past X min(s).
@brettsam No, my AssemblyInfo.cs is fine and projects .csproj file is clean
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.0-beta7" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.2.2-beta3" />
<PackageReference Include="Microsoft.Azure.WebJobs.ServiceBus" Version="3.0.0-beta5" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.13" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Could it be connected with the way I use CosmosDb attribute?
[CosmosDB(Constants.DatabaseName
, Constants.CollectionName
, ConnectionStringSetting = Constants.CosmosDbConnectionString)] IReadOnlyList<Document> documents
The AssemblyInfo questions were for @Saphirim. Sorry, trying to help two people with different problems in the same thread :-)
@GvozdevDA, your problem is likely due to our VS tools. We're working on an update right now and hope to have released ASAP. I'll update here when the release is live.
@brettsam Thanks a lot, I'll wait for further updates.
@brettsam
Got the duplicate attribuites thing fixed thanks to your link. Now back at the old problem, output of the function host console:
[4/4/2018 10:16:26 AM] Reading host configuration file 'C:\Users\ArasAdmin\source\repos\CosmosDB-ARAS-PoC\ArasPoCAzureFunctions\TestDataArasIntegration\bin\Debug\netstandard2.0\host.json'
[4/4/2018 10:16:26 AM] Host configuration file read:
[4/4/2018 10:16:26 AM] {}
[4/4/2018 10:16:26 AM] Loaded custom extension: CosmosDBConfiguration from 'referenced by: Method='TestDataArasIntegration.TestDataArasAdapter.Run', Parameter='documents'.'
[4/4/2018 10:16:28 AM] ScriptHost initialization failed
[4/4/2018 10:16:28 AM] Microsoft.Azure.WebJobs.Extensions.CosmosDB: Method not found: 'Void Microsoft.Azure.WebJobs.Host.Config.FluentBindingRule`1.AddValidator(System.Action`2<!0,System.Type>)'.
Will be waiting for some updates here too.
Arrived here by way of searching the same error (Microsoft.Azure.WebJobs.Extensions.CosmosDB: Method not found: 'Microsoft.Azure.WebJobs.Host.TraceWriter Microsoft.Azure.WebJobs.Host.Config.ExtensionConfigContext.get_Trace()') .
But I followed the link to the announcement, and saw the suggestion to use func extensions sync and that did the trick.
I get this error when I just try to follow the newbie-friendly instructions. I simply:
sudo npm install -g azure-functions-core-tools@core --unsafe-perm true
(needed the last flag as per the instructions)func init MyFunctionProj
func extensions install --package Microsoft.Azure.WebJobs.Extensions.CosmosDB --version 3.0.0-beta6
func new --language JavaScript --template HttpTrigger --name MyHttpTrigger
func host start
In addition, I also use the Azurite Azure Blob, Queue, and Table Storage Emulator, and configured it according to the instructions with UseDevelopmentStorage=true
as the value for my AzureWebJobsStorage
and AzureWebJobsDashboard
connection strings.
Scrapping that project, and re-creating one without the CosmosDB extension installation works like a charm. Also, running the exensions sync command did not make it work.
Edited to add: if the newbie-friendly instructions are out of date (possible since they refer to a beta version), then please update that as well as needed if some later version is known to be compatible with this newly released version of Functions.
@llarsson can you try func extensions install --package Microsoft.Azure.WebJobs.Extensions.CosmosDB --version 3.0.0-beta7
instead. There was a recent breaking change released, and the newest version of the extension has been updated appropriately. The beta6 package is several months old.
Also since I think the doc is out of date I filed: https://github.com/Azure/Azure-Functions/issues/752
@llarson while you're at it, can you watch for this problem? https://github.com/Azure/azure-functions-core-tools/issues/424 I've had it on two machines now
@paulbatum and @julielerman, running the same commands as in my previous comment, but with version 3.0.0-beta7
worked for me. At least to the level that the Function Host started up, and noted that the CosmosDB extension had been loaded.
So from my perspective, a simple documentation update should suffice. Does using that version solve the problem for you too, @gauraviitr?
Oh, glad for the notification via @llarsson note. I meant to come and update as well. The beta7 has removed this problem (binding) as well as the problem with the installation of the cosmosdb package. I noted the latter fix in my above linked issue. On my machines, there is also no more need to sync the extensions. So all that's left along these lines is that magical installation of the package based on the type: cosmosdb in the function.json which is noted in another issue. Yay! Thanks for all of your hard work on these tools!
@llarsson I had tried this even before they posted here advising use of beta7. The binding was done but I ran into a new error:
"ScriptHost initialization failed [3/29/2018 12:05:48 AM] Microsoft.Azure.WebJobs.Extensions.CosmosDB: Method not found: 'Void Microsoft.Azure.WebJobs.Host.Config.FluentBindingRule1.AddValidator(System.Action2<!0,System.Type>)'. Listening on http://localhost:7071/ Hit CTRL-C to exit... Object reference not set to an instance of an object."
@gauraviitr maybe there is some other aspect to this that i'm missing, but you should definitely not get that error if you've installed 3.0.0-beta7. There should be an extensions.csproj file that was created after running the extension install command. Can you check it? There should be an entry pointing to beta7.
Well, I have "proof" that this should work on a correctly configured Ubuntu 16.04 machine via the magic of Docker and a horribly ugly quickly hacked-together Dockerfile and accompanying entrypoint script.
Put this into a file called entrypoint.sh
and mark it executable chmod +x entrypoint.sh
:
#!/bin/sh
cd /functions
exec func host start
Now put the following into a Dockerfile
:
FROM ubuntu:xenial
RUN apt-get update && apt-get dist-upgrade -y && apt-get install curl -y
# Install node according to instructions
# https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && apt-get install -y nodejs
# Install dotnet according to instructions
# https://www.microsoft.com/net/learn/get-started/linux/ubuntu16-04
RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg && \
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg && \
echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list && \
apt-get update && \
apt-get install dotnet-sdk-2.1.104 -y
# Install Azure Functions Core Tools
RUN npm install -g azure-functions-core-tools@core --unsafe-perm true
# Init a function and try to install CosmosDB extension
WORKDIR /
RUN func init functions
WORKDIR /functions
RUN func extensions install --package Microsoft.Azure.WebJobs.Extensions.CosmosDB --version 3.0.0-beta7
RUN func new --language JavaScript --template HttpTrigger --name MyHttpTrigger
ADD entrypoint.sh /entrypoint.sh
ENTRYPOINT /entrypoint.sh
If you build that docker build -t issue2598 .
and then run it docker run -it issue2598
(-it
makes it "interactive" enough so that you can kill via Ctrl-C, as usual), you will see that the Function host starts up correctly and that the CosmosDB extension is loaded correctly.
So, @gauraviitr, can it be that you have a too old version of either node or dotnet or something?
I tried this again (beta7). When I reopen the editor this is what I get: Starting OmniSharp server at 4/12/2018, 1:13:11 AM Target: c:\Users\gaura\Documents\threecomma0329
OmniSharp server started Path: C:\Users\gaura.vscode\extensions\ms-vscode.csharp-1.14.0.omnisharp\OmniSharp.exe PID: 7628
Starting OmniSharp on Windows 6.2.9200.0 (x64)
Located 1 MSBuild instance(s)
1: StandAlone 15.0 - "C:\Users\gaura\.vscode\extensions\ms-vscode.csharp-1.14.0\.omnisharp\msbuild\15.0\Bin"
MSBUILD_EXE_PATH environment variable set to 'C:\Users\gaura\.vscode\extensions\ms-vscode.csharp-1.14.0\.omnisharp\msbuild\15.0\Bin\MSBuild.exe'
Registered MSBuild instance: StandAlone 15.0 - "C:\Users\gaura\.vscode\extensions\ms-vscode.csharp-1.14.0\.omnisharp\msbuild\15.0\Bin"
CscToolExe = csc.exe
CscToolPath = C:\Users\gaura\.vscode\extensions\ms-vscode.csharp-1.14.0\.omnisharp\msbuild\15.0\Bin\Roslyn
MSBuildExtensionsPath = C:\Users\gaura\.vscode\extensions\ms-vscode.csharp-1.14.0\.omnisharp\msbuild
MSBuildToolsPath = C:\Users\gaura\.vscode\extensions\ms-vscode.csharp-1.14.0\.omnisharp\msbuild\15.0\Bin
Detecting Cake files in 'c:\Users\gaura\Documents\threecomma0329'.
Could not find any Cake files
Initializing in c:\Users\gaura\Documents\threecomma0329
Auto package restore: False
Update workspace context
Resolving projects references
No solution files found in 'c:\Users\gaura\Documents\threecomma0329'
Queue project update for 'c:\Users\gaura\Documents\threecomma0329\functions-extensions\extensions.csproj'
Loading project: c:\Users\gaura\Documents\threecomma0329\functions-extensions\extensions.csproj
Detecting CSX files in 'c:\Users\gaura\Documents\threecomma0329'.
Could not find any CSX files
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
Configuration finished.
Omnisharp server running using Stdio at location 'c:\Users\gaura\Documents\threecomma0329' on host 22332.
Detected package downgrade: System.Net.Primitives from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version.
extensions -> Microsoft.Azure.WebJobs.Extensions.CosmosDB 3.0.0-beta7 -> Microsoft.Azure.DocumentDB.ChangeFeedProcessor 1.2.0 -> Microsoft.Azure.DocumentDB.Core 1.5.1 -> System.Net.NetworkInformation 4.1.0 -> System.Net.Sockets 4.1.0 -> runtime.win.System.Net.Sockets 4.3.0 -> System.Net.Primitives (>= 4.3.0) extensions -> Microsoft.Azure.WebJobs.Extensions.CosmosDB 3.0.0-beta7 -> Microsoft.Azure.DocumentDB.ChangeFeedProcessor 1.2.0 -> Microsoft.Azure.DocumentDB.Core 1.5.1 -> System.Net.NetworkInformation 4.1.0 -> System.Net.Primitives (>= 4.0.11)
Detected package downgrade: System.Security.Principal.Windows from 4.3.0 to 4.0.0. Reference the package directly from the project to select a different version.
extensions -> Microsoft.Azure.WebJobs.Extensions.CosmosDB 3.0.0-beta7 -> Microsoft.Azure.DocumentDB.ChangeFeedProcessor 1.2.0 -> Microsoft.Azure.DocumentDB.Core 1.5.1 -> System.Net.NetworkInformation 4.1.0 -> System.Net.Sockets 4.1.0 -> runtime.win.System.Net.Sockets 4.3.0 -> System.Security.Principal.Windows (>= 4.3.0) extensions -> Microsoft.Azure.WebJobs.Extensions.CosmosDB 3.0.0-beta7 -> Microsoft.Azure.DocumentDB.ChangeFeedProcessor 1.2.0 -> Microsoft.Azure.DocumentDB.Core 1.5.1 -> System.Net.NetworkInformation 4.1.0 -> System.Security.Principal.Windows (>= 4.0.0) c:\Users\gaura\Documents\threecomma0329\functions-extensions\extensions.csproj
Adding project 'c:\Users\gaura\Documents\threecomma0329\functions-extensions\extensions.csproj'
Update project: extensions
Fix: The documentation at https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb suggests that the "type" in function.json file be "documentDB". This fails for 2.x runtime. Changing this to cosmosDB fixes the issue.
The binding works now. Hence, closing the issue.
Note: I still see this OmniSharp issue (which seems appropriate for a different thread).
I'm running the v2.x runtime nodeJS 8.9.4 Tried to bind the CosmosDB after registering the extension. Receiving this error and cant use the function until its' resolved: The function runtime is unable to start. Microsoft.Azure.WebJobs.Extensions.CosmosDB: Method not found: 'Microsoft.Azure.WebJobs.Host.TraceWriter Microsoft.Azure.WebJobs.Host.Config.ExtensionConfigContext.get_Trace()'
On invoking the function I receive the message 'Function host is not running'