简体   繁体   中英

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

I have created a Runbook and added below cmdlet

   Get-AzFunctionApp  | Stop-AzFunctionApp

I get below error

The term 'Get-AzFunctionApp' is not recognized as the name of a cmdlet,

I have imported all the below modules but no luck

在此处输入图像描述

After adding 'Az.Functions' I get below error

Failed Cannot validate argument on parameter 'SubscriptionId'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. (The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.)

The cmdlet Get-AzFunctionApp / Stop-AzFunctionApp are included in this module: 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:

$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.

To import Az.Functions module into your Automation account, do the following:

  1. From your Automation account, under Shared Resources , select Modules .
  2. Select Browse Gallery .
  3. In the search bar, enter the module name ( Az.Functions ).
  4. On the PowerShell Module page, select Import to import the module into your Automation account.

导入模块

You can also import the module through the PowerShell Gallery . Choose the Azure Automation tab and select Deploy to Azure Automation from here: Az.Functions .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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