从 Visual Studio 2022 开始使用 Dotnet 6 部署的 Azure 函数不起作用
Azure function deployed with Dotnet 6 from Visual Studio 2022 doesn't work
所以我有一个基本的功能。代码可以在下面看到。我可以在本地 运行 它没有任何问题。我可以从浏览器和邮递员调用它。但是当我 运行 对 Azure Functions 进行基本部署时,它说部署成功,但我无法从浏览器或邮递员调用它。我记得创建函数 AuthorizationLevel.Anonymous 所以我不必包含 apikey 或任何 auth.
我已尝试将此功能部署到多个区域以及 Windows 和 Linux 功能。
https://someawesomefunction20211215085831.azurewebsites.net/api/Swag
对
http://localhost:7071/api/Swag
*编辑:
添加了产品的 GIF,无法使用来自 Visual Studio 的部署的默认设置。
我部署的函数没有显示在函数概览中???这可能是问题所在吗?
public static class Awesomeness
{
[FunctionName("Swag")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;
string responseMessage = string.IsNullOrEmpty(name)
? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
: $"Hello, {name}. This HTTP triggered function executed successfully.";
return new OkObjectResult(responseMessage);
}
}
问题已解决 post 关闭解决方案并在 visual studio 2022 年再次打开它。建议他们在将函数从本地发布到 Azure 函数应用程序时从包文件启用 运行 . Post 该用户能够在功能应用程序下看到该功能并能够从 post 人那里触发该功能。
所以我有一个基本的功能。代码可以在下面看到。我可以在本地 运行 它没有任何问题。我可以从浏览器和邮递员调用它。但是当我 运行 对 Azure Functions 进行基本部署时,它说部署成功,但我无法从浏览器或邮递员调用它。我记得创建函数 AuthorizationLevel.Anonymous 所以我不必包含 apikey 或任何 auth.
我已尝试将此功能部署到多个区域以及 Windows 和 Linux 功能。
https://someawesomefunction20211215085831.azurewebsites.net/api/Swag
对
http://localhost:7071/api/Swag
*编辑:
添加了产品的 GIF,无法使用来自 Visual Studio 的部署的默认设置。
我部署的函数没有显示在函数概览中???这可能是问题所在吗?
public static class Awesomeness
{
[FunctionName("Swag")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;
string responseMessage = string.IsNullOrEmpty(name)
? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
: $"Hello, {name}. This HTTP triggered function executed successfully.";
return new OkObjectResult(responseMessage);
}
}
问题已解决 post 关闭解决方案并在 visual studio 2022 年再次打开它。建议他们在将函数从本地发布到 Azure 函数应用程序时从包文件启用 运行 . Post 该用户能够在功能应用程序下看到该功能并能够从 post 人那里触发该功能。