当尝试在本地调试azure函数时,出现以下错误
[14-03-2019 14:09:22] System.Private.CoreLib:发生异常 执行函数:CreateDocument。 Microsoft.Azure.WebJobs.Host: 异常绑定参数“ graphToken”。 Microsoft.Azure.WebJobs.Host:访问时出错 “ X-MS-TOKEN-AAD-ID-TOKEN”:属性不存在。
项目参考如下
功能代码如下:
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
[Token( Identity = TokenIdentityMode.UserFromRequest,
IdentityProvider = "AAD",
Resource = "https://graph.microsoft.com")] string graphToken,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request. " + graphToken);
}
local.settings.json如下
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"WEBSITE_AUTH_CLIENT_ID": "<my application id>",
"WEBSITE_AUTH_CLIENT_SECRET": "<my secret key>",
"WEBSITE_AUTH_OPENID_ISSUER": "https://sts.windows.net/<my tenantid>"
},"Host": {
"LocalHttpPort": 7071,
"CORS": "*"
}
}
注意::使用Visual Studio 2017发布并在浏览器功能中访问端点时有效。