Failed to create rule source with exception: The term 'New-AzScheduledQueryRuleSource' is not recognized as the name of a cmdlet, function, script file, or operable program.

Majid Qureshi 5 Reputation points
2023-02-20T06:03:40.03+00:00

I am creating Log analystics workspace, resource group, Azure arc, Data Collection rules and creating alerts.

I have installed latest version of Az modules on my PC, I am successfully able to create Workspace, resource group , On-board Azure ARC on windows machine and Data collection rules but I am unable to create Alerts. I have investigated and found that when Az.Monitor with version other than 1.4.1 installed on machine then the alerts are not creating giving error : Failed to create rule source with exception: The term 'New-AzScheduledQueryRuleSource' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

After that I uninstalled Az.Monitor version 4.2.1 and install the version 1.4.1 then I am able to create the Alerts but unable to create Data collection rules. can you please help me out that which version of Az.Monitor allow both the Data collection rules and alert creation.

Giving below error while creating Alert:

Alert query: Event | where EventLog == "Security" and Source == "Microsoft-Windows-Eventlog" and EventID == "1102"
Failed to create rule source with exception: The term 'New-AzScheduledQueryRuleSource' is not recognized as the name of 
a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify 
that the path is correct and try again.
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
Community Center | Not monitored
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Toby Scamell 10 Reputation points
    2024-02-19T11:12:22.9766667+00:00

    This command no longer exists on Az.Monitor You'll need to change your command to use the updated commands, currently these are listed: https://learn.microsoft.com/en-gb/powershell/module/az.monitor/new-azscheduledqueryrule?view=azps-11.3.0

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.