gpt4 book ai didi

powershell - Azure 自动化 - 每天自动重新启动一次 Web 应用程序的 Runbook

转载 作者:行者123 更新时间:2023-12-02 23:02:25 25 4
gpt4 key购买 nike

我根本没有太多使用 PowerShell 的经验 - 我想做的是使用我的 Azure 自动化服务来设置一个 Runbook,该 Runbook 将在每晚凌晨 1 点自动重新启动我的一个 Azure Web 应用程序。

是否可以使用 Powershell/Azure 自动化来完成此任务?

最佳答案

这是完全可能的,您需要创建一个 Azure 自动化帐户,创建一个与计划相关的 Runbook 并使用如下内容:

$connectionName = "AzureRunAsConnection" # this is the default connection created when you provision the Automation account,
# you might need to change this to your own connection name
$servicePrincipalConnection = Get-AutomationConnection -Name $connectionName

$null = Add-AzureRmAccount `
-ServicePrincipal `
-TenantId $servicePrincipalConnection.TenantId `
-ApplicationId $servicePrincipalConnection.ApplicationId `
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint

$null = Select-AzureRmSubscription -SubscriptionId 'SUB_GUID' ` # Needed if you have more than 1 subscription

Restart-AzureRmWebApp -ResourceGroupName xxx -Name WebAppName

关于powershell - Azure 自动化 - 每天自动重新启动一次 Web 应用程序的 Runbook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45394859/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com