我如何以编程方式重新启动Azure App Service实例?

问题描述 投票:3回答:1

我有一组Azure应用服务,偶尔有单个实例变得不正常。我们已经确定,通过Advanced Diagnostics重新启动该特定实例将使该实例备份。

我们希望建立一些自动化机制,以便一旦检测到此不正常的实例,我们将自动运行并重新启动该实例。请注意,我们只想重新启动不正常的instance,而不是重新启动整个App Service。

我们找到了以下方法:

public static Task RestartAsync(
  this IWebAppsOperations operations, 
  string resourceGroupName, 
  string name, 
  bool? softRestart = null, 
  bool? synchronous = null, 
  CancellationToken cancellationToken = default
);

Microsoft.Azure.Management.AppService.Fluent名称空间WebAppsOperationsExtensions类下,以及非Fluent ARM库中的类似方法。但是,这些仅允许我们重新启动整个App Service。我们希望将干扰降到最低,并且仅针对特定实例进行重启。

是否存在通过.NET库或REST API(我们可以自行构建请求的机制)的机制,该机制将允许我们重新启动单个App Service实例?

azure azure-web-sites azure-web-app-service
1个回答
1
投票

an MSDN blog post中说:

WebApp的Azure PowerShell cmdlet允许您重新启动WebApp或WebApp插槽。但是,它们不允许重新启动WebApp中的实例

但是其中包含一个PowerShell脚本,该脚本会在一定延迟下重新启动所有实例。

此外,如果您检查Azure REST API,则有两种方法可以杀死实例上的进程。我认为,仅凭该特定实例终止w3wp.exe流程就足够了:

喜欢这个:

DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/instances/{instanceId}/processes/{processId}?api-version=2016-08-01
© www.soinside.com 2019 - 2024. All rights reserved.