Azure HTTP function trigger 2.x with Cosmos DB Output local dev host failing

别来无恙 提交于 2019-12-02 07:29:43

It's caused by referencing Microsoft.Azure.WebJobs.Extensions.CosmosDB of latest version 3.0.1-beta1/2 in old function runtime 2.0.11960.0. Microsoft.NET.Sdk.Functions 1.0.19 and Microsoft.Azure.WebJobs.Extensions.CosmosDB 3.0.1-beta2 depends on runtime 2.0.12050.0.

Check this issue with relevant error info for breaking changes of latest runtime 2.0.12050.0.

If you don't want to move to latest runtime for now, downgrade Microsoft.Azure.WebJobs.Extensions.CosmosDB to 3.0.0-beta7 and Microsoft.NET.Sdk.Functions to 1.0.14.

Else just make sure VS consumes the latest function runtime 2.0.12050.0.

  1. On VS menus-> Extensions and Updates. Find Azure Functions and Web Jobs Tools. Make sure it's >= 15.8.5023.(Need to update VS to 15.8 first).

  2. Delete old Function Core tools(Cli) folder %localappdata%\AzureFunctionsTools.

  3. Restart VS and create a new Azure function. Wait at the creation dialog for VS to download new Cli and templates, until we see the tip change to Updates are ready.

Update

  1. Check Cli output, I am afraid older version 2.0.11651.0 is in use.

    Starting Host (HostId=xxx, InstanceId=xxx, Version=2.0.11651.0, ...)
    

    Go to %localappdata%\AzureFunctionsTools\Releases, you may also see an empty folder 2.5.1.

    The download failed due to some reason like network. Repeat the steps above again. If it doesn't work, try to download Cli manually. Close VS first.

    1). Open %localappdata%\AzureFunctionsTools\feed.json to find latest download url of v2.

    e.g. cli: https://functionscdn.azureedge.net/public/2.0.1-beta.36/Azure.Functions.Cli.win-x86.2.0.1-beta.36.zip.

    2). Rename unzipped folder as cli, put it under 2.5.1.

    3). Move templates folder in cli folder to 2.5.1.

    4). Create a manifest.json under 2.5.1.(Change your UserName)

    {
     "ReleaseName": "2.5.1",
     "CliEntrypointPath": "C:\\Users\\UserName\\AppData\\Local\\AzureFunctionsTools\\Releases\\2.5.1\\cli\\func.exe",
     "TemplatesDirectory": "C:\\Users\\UserName\\AppData\\Local\\AzureFunctionsTools\\Releases\\2.5.1\\templates",
     "FunctionsExtensionVersion": "~2",
     "SdkPackageVersion": "1.0.19"
    }
    
  2. Function SDK references Microsoft.AspNetCore.Mvc.Abstractions 2.1.0 by design. Remove 2.2.0-preview1-35029 or we may get error when executing.

    Microsoft.Azure.WebJobs.Host: Exception binding parameter 'req'. System.Private.CoreLib: Cannot create an abstract class.
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!