簡體   English   中英

Azure function 從 Visual Studio 2022 部署的 Dotnet 6 不起作用

[英]Azure function deployed with Dotnet 6 from Visual Studio 2022 doesn't work

所以我有一個基本的function。 代碼如下所示。 我可以在本地運行它而沒有任何問題。 我可以從瀏覽器和 postman 調用它。 但是當我對 Azure 函數運行基本部署時,它說部署成功,但我無法從瀏覽器或 postman 調用它。 我記得制作 function AuthorizationLevel.Anonymous 所以我不必包含 apikey 或任何身份驗證。

我試圖將這個 function 部署到幾個區域,並同時部署到 Windows 和 Linux futures。

https://someawesomefunction20211215085831.azurewebsites.net/api/Swag

對比

http://localhost:7071/api/Swag

*編輯:

添加了 prod 的 GIF,不適用於 Visual Studio 部署的默認設置。

在此處輸入圖像描述

我部署的 function 沒有出現在功能概覽中??? 這可能是問題嗎?

在此處輸入圖像描述

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);
    }
}

Issue got resolved post closing the solution & opening it again in visual studio 2022. Suggested them to enable run from package file while publishing the function from local to Azure function app. 發布該用戶能夠在 function 應用程序下看到 function 並且能夠從郵遞員那里觸發 function。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM