[英]Stop an Azure Function App by using Runbook
I have an Azure Function app running which I need to stop and start on a schedule.我有一个 Azure Function 应用程序正在运行,我需要按计划停止和启动它。 tried to automate it by Azure Automation Account using Runbook with PowerShell script.
尝试使用带有 PowerShell 脚本的 Runbook 通过 Azure 自动化帐户对其进行自动化。
Will a single line of command work?一行命令行得通吗?
I tried below.我在下面试过。
Update-AzFunctionAppSetting -Name MyFUNCTION_APP_NAME -ResourceGroupName MyRESOURCE_GROUP_NAME -AppSetting @{"AzureWebJobs.MyFunctionName.Disabled" = "true"}
upon running it throws error -运行时会抛出错误 -
Failed
You cannot call a method on a null-valued expression.
Do I have to pass the name of the function app as a variable/parameter or something?我是否必须将 function 应用程序的名称作为变量/参数或其他内容传递? Or just one line above is all that is needed?
或者只需要上面一行?
Tried different syntaxes found around inte.net but none worked.尝试了在 inte.net 周围发现的不同语法,但都没有用。
Thanks @Anand Sowmithiran for the comment.感谢@Anand Sowmithiran 的评论。
When I run the below commands Iam able to Stop the Azure Function.当我运行以下命令时,我能够停止 Azure Function。
Get-AzFunctionApp -Name FuncAppName -ResourceGroupName YourRGGroupName| Stop-AzFunctionApp -Force
OR要么
Stop-AzFunctionApp -Name FunctionApp2Jan -ResourceGroupName YourRGGroupName -Force
Before Running the command:运行命令之前:
After running the Stop Command:运行停止命令后:
Update-AzFunctionAppSetting -Name FunctionApp2Jan ->ResourceGroupName YourRGName -AppSetting >{"AzureWebJobs.MyFunctionName.Disabled" = "true"}
App Settings in Configuration Section:配置部分的应用程序设置:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.