Azure / Azure/azure-functions-host
Microsoft.Azure.KeyVault (Microsoft.Azure.Services.AppAuthentication) issue on functions runtime 2.0.11651-alpha
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
Hi, I'm developing Azure Functions v2 in Visual Studio with latest tools installed. (.NET Core)
After an attempt to apply Azure KeyVault secrets to my functions (like described here https://medium.com/statuscode/getting-key-vault-secrets-in-azure-functions-37620fd20a0b) I've faced with issue on startup of function app in Azure.
Kudu logs dump says the following:
```
Hosting environment: Production
Content root path: D:\Program Files (x86)\SiteExtensions\Functions\2.0.11651-alpha
Now listening on: http://localhost:12938
Warning: Only got partial types from assembly: MiddleWare.External.Functions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Exception message: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Microsoft.Azure.WebJobs.Host.Indexers.DefaultTypeLocator.FindTypes(Assembly assembly, IEnumerable`1 extensionAssemblies) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\DefaultTypeLocator.cs:line 120
```
#### Investigative information
- Timestamp: 2018-05-14 15:31:55.862
- Function App version (1.0 or 2.0-beta): v2.0-beta
- Function App name:
- Function name(s) (as appropriate):
- Invocation ID:
- Region:
#### Repro steps
Provide the steps required to reproduce the problem:
#### Expected behavior
1. Azure Functions working, retrieving secrets from the Key Vault instance on demand, correctly authenticating in Azure AD.
#### Actual behavior
Azure functions not starting, manual triggering causes 400 error.
Kudu log dump provided above.
#### Known workarounds
Implementing custom Token Provider like on the screen below resolves the issue.

So I think the issue is in the AppAuthentication package.
I've debugged functions remotely in visual studio, but unfortunately it takes a lot of time to attach, and filter all not related exceptions during the debugging of actual issue with AzureServiceTokenProvider.
As soon as I got rid of the Microsoft.Azure.Services.AppAuthentication dependency, functions are able to start.
Now, switching to v1 version and will implement it there.
So, not waiting for a quick answer, just want to recollect the thoughts and maybe I've missed something.
Contributor guide
Assessment
This issue has not been assessed yet.