简体   繁体   English

命令“Get-AzFunctionApp”在 Azure 自动化运行手册中不起作用

[英]The command 'Get-AzFunctionApp ' is not working in Azure Automation Runbook

I have created a Runbook and added below cmdlet我创建了一个Runbook并在 cmdlet 下添加

   Get-AzFunctionApp  | Stop-AzFunctionApp

I get below error我得到以下错误

The term 'Get-AzFunctionApp' is not recognized as the name of a cmdlet,术语“Get-AzFunctionApp”未被识别为 cmdlet 的名称,

I have imported all the below modules but no luck我已经导入了以下所有模块但没有运气

在此处输入图像描述

After adding 'Az.Functions' I get below error添加“Az.Functions”后,出现以下错误

Failed Cannot validate argument on parameter 'SubscriptionId'.失败 无法验证参数“SubscriptionId”上的参数。 The argument is null or empty.参数为 null 或为空。 Provide an argument that is not null or empty, and then try the command again.提供一个不是 null 或空的参数,然后重试该命令。 (The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.) (参数为 null 或空。提供一个非 null 或空的参数,然后重试该命令。)

The cmdlet Get-AzFunctionApp / Stop-AzFunctionApp are included in this module: Az.Functions . cmdlet Get-AzFunctionApp / Stop-AzFunctionApp包含在此模块中: Az.Functions

Please import this module and then the functions related operation will work.请导入此模块,然后功能相关操作将起作用。

Here is an example(please note that add the -Force parameter for Stop-AzFunctionApp ), it works as per my testing:这是一个示例(请注意为Stop-AzFunctionApp添加-Force参数),它根据我的测试工作:

$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Connect-AzAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint

Get-AzFunctionApp -ResourceGroupName xxx | Stop-AzFunctionApp -Force

From the screenshot you posted, it looks like you are missing the Az.Functions module that contains both the Get-AzFunctionApp and Stop-AzFunctionApp cmdlets.从您发布的屏幕截图中,您似乎缺少包含Get-AzFunctionAppStop-AzFunctionApp cmdlet 的Az.Functions模块。

To import Az.Functions module into your Automation account, do the following:要将Az.Functions模块导入您的自动化帐户,请执行以下操作:

  1. From your Automation account, under Shared Resources , select Modules .在您的自动化帐户中,在Shared Resources下,select Modules
  2. Select Browse Gallery . Select浏览图库
  3. In the search bar, enter the module name ( Az.Functions ).在搜索栏中,输入模块名称 ( Az.Functions )。
  4. On the PowerShell Module page, select Import to import the module into your Automation account.在 PowerShell 模块页面上,select Import将模块导入您的自动化帐户。

导入模块

You can also import the module through the PowerShell Gallery .您也可以通过PowerShell Gallery导入模块。 Choose the Azure Automation tab and select Deploy to Azure Automation from here: Az.Functions .从此处选择Azure 自动化选项卡和 select部署到 Azure 自动化Az.Functions

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM