简体   繁体   English

Azure Function 插槽交换前的健康检查?

[英]Azure Function healthcheck before slot swap?

I have a function app with a staging slot.我有一个带有暂存槽的 function 应用程序。 I'd like to be able to deploy to the staging slot, and have the app perform an auto swap to the production slot.我希望能够部署到暂存槽,并让应用自动切换到生产槽。 In the docs for App Service, you're able to write custom warm-up, where "The swap operation waits for this custom warm-up to finish before swapping with the target slot."在 App Service 的文档中,您可以编写自定义预热,其中“交换操作等待此自定义预热完成,然后再与目标槽交换。”

Is this possible with an Azure Function? Azure Function 可以吗? There seem to be warm-up triggers as specified here , but nothing related to the swap operation.似乎有此处指定的预热触发器,但与交换操作无关。

My situation is on deployment to the staging slot, I'd like the swap to get a healthy response from a custom endpoint before continuing with the swap.我的情况是部署到暂存槽,我希望交换在继续交换之前从自定义端点获得健康响应。 Is this possible with Azure Functions?这可能与 Azure 功能有关吗?

We can Create a Function App in Azure portal (or) in Visual Studio.我们可以在 Azure 门户(或)Visual Studio 中创建一个Function App The swap operation can be done in Development Slot.交换操作可以在 Development Slot 中完成。 As per my knowledge, healthy response from a custom endpoint before continuing with the swap production Slot Swap.据我所知,在继续进行交换生产插槽交换之前,来自自定义端点的响应是健康的。 This can be done in Health Check in Monitoring within azure function you created.这可以在您创建的azure function中的 Monitoring 中的Health Check中完成。

The azure function is created in Visual Studio by following the below steps. azure function 是按照以下步骤在 Visual Studio 中创建的。

  • Open Visual Studio and Create a new project打开 Visual Studio 并创建一个新项目

在此处输入图像描述

  • Search for azure function and select it.搜索 azure function 和 select 它。

在此处输入图像描述

  • Enter the Project name and on click on create输入项目名称,然后单击创建

在此处输入图像描述

  • Create a Azure Function in C# and replace the code as mentioned below.在C#中新建一个Azure Function,替换如下代码。

在此处输入图像描述

 using Microsoft.Azure.WebJobs;
    using Microsoft.Extensions.Logging;
    
    namespace WarmupSample
    {
    
        //Declare shared dependencies here
    
        public static class Warmup
        {
            [FunctionName("Warmup")]
            public static void Run([WarmupTrigger()] WarmupContext context,
                ILogger log)
            {
                //Initialize shared dependencies here
    
                log.LogInformation("Function App instance is warm 🌞🌞🌞");
            }
        }
    }
  • Run the application locally在本地运行应用程序

在此处输入图像描述

  • On the Solution Explorer, right click on the project and Select the Publish option在解决方案资源管理器上,右键单击项目和 Select 发布选项

在此处输入图像描述

  • Select Azure and click on next Select Azure 点击下一步

在此处输入图像描述

  • Select Azure Function and click on next Select Azure Function 点击下一步

在此处输入图像描述

  • Create a new Azure Function新建一个 Azure Function

在此处输入图像描述

  • Enter the Function name the subscription name, Resource group and Click on Create输入 Function 名称订阅名称,资源组并单击创建

在此处输入图像描述

  • Select your Function app(which you just created) and click on Finish Select 你的 Function 应用程序(你刚创建的)然后点击完成

在此处输入图像描述

  • Click on Publish and go the Azure Functions in Portal在Portal中点击Publish和go Azure功能

在此处输入图像描述

  • Select the Azure Function you published in Azure account within azure portal Select Azure Function 你发表在Azure账号内 azure 传送门

在此处输入图像描述

  • In Azure function you created, Click on Swap Select the Source and Target and click on Swap.在您创建的 Azure function 中,单击 Swap Select the Source and Target 然后单击 Swap。

在此处输入图像描述

  • To configure custom endpoint for healthy response , go to the instance and check whether the app is Healthy or Unhealthy, following the below path with /要为健康响应配置自定义端点,go 到实例并检查应用程序是健康还是不健康,请遵循以下路径 /

在此处输入图像描述

  • Go to the instance to check if the app is Healthy and then select restart. Go 到实例检查应用程序是否健康,然后 select 重新启动。 You will get another window to test the health of other Function( if required).您将获得另一个 window 来测试其他功能的健康状况(如果需要)。

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Function 应用部署槽交换不交换 - Function app deployment slot swap doesn't swap Azure 插槽交换作业处理器失败:无法为站点交换插槽,因为插槽中的工作进程中止了预热请求 - Azure Slot Swap Job Processor failed: Cannot swap slots for site because the worker process in slot aborted the warmup request 将代码从 Azure repo 部署到 Function app slot - Deploy code from Azure repo to Function app slot 是否可以为 Azure Function 部署槽创建 Azure 存储事件网格订阅? - Is it possible to create an Azure Storage Event Grid Subscription to an Azure Function deployment slot? Google Cloud Run 在 Healthcheck 健康之前启动容器 - Google Cloud Run Starts Container Before Healthcheck is Healthy Azure API 管理-可用性测试-如何获取APIM的HealthCheck url - Azure API Management - Availability Tests - How to get the HealthCheck url of APIM 部署到唯一 Azure Function 应用程序部署槽并返回 URL 和 Github 操作 - Deploy to Unique Azure Function App Deployment Slot and Return URL with Github Actions 在将其部署到 Azure 之前,我们如何保护 Azure Function 中的 local.settings.json 文件 - How we can secure the local.settings.json file inside our Azure Function before deploying it to Azure Azure Webapp Keyvault 引用,带有用户分配的暂存槽标识 - Azure Webapp Keyvault reference with user-assigned identity for staging slot Google Cloud Functions 2 Terraform 部署失败(错误等待创建function,容器健康检查失败) - Google Cloud Functions 2 Terraform fails to deploy (error waiting for creating function, container healthcheck failed)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM