Search code examples
azureazure-monitoringazure-alerts

New-AzActionGroupReceiver How to set up voice call as a New Action Group?


Reference: https://learn.microsoft.com/bs-latn-ba/powershell/module/az.monitor/New-AzActionGroupReceiver?view=azps-3.3.0&viewFallbackFrom=azps-2.6.0

The following code works without any error while I am trying to create a new action group to use with new Alert in Azure Monitor.

import-module Az.Monitor
#Setting up action group
$emailaddress = 'first.lastname@domainName.com'
$phoneNumber = '1234567890'
$emailDBA = New-AzActionGroupReceiver -Name 'emailDBA' -EmailAddress $emailaddress
$smsDBA = New-AzActionGroupReceiver -Name 'smsDBA' -SmsReceiver -CountryCode '1' -PhoneNumber $phoneNumber 

Set-AzActionGroup `
    -Name 'notifydbadeadlock' `
    -ResourceGroupName $resourceGroupName `
    -ShortName 'deadlock' `
    -Receiver $emailDBA,$smsDBA

As per the documentation, I should also be able to add voicemail by using the following code.

$phoneDBA = New-AzActionGroupReceiver -Name 'phoneDBA' -VoiceCountryCode '1' -VoicePhoneNumber $phoneNumber -VoiceReceiver

I get an error message.

New-AzActionGroupReceiver : A parameter cannot be found that matches parameter name 'VoiceCountryCode'. At line:1 char:56 + ... New-AzActionGroupReceiver -Name 'phoneDBA' -VoiceCountryCode '1' -Vo ... + ~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [New-AzActionGroupReceiver], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Azure.Commands.Insights.ActionGroups.NewAzureRmActionGroupReceiverCommand

I did update the module Az.Monitor.

How can I solve this?


Solution

  • I had the same issue. After some research, I found that you should use powershell v6, then install Az.Monitor, version 1.5.0, it can work well.

    Steps as below:

    1.Nav to the powershell v6 site -> then scroll down to the end of the page -> download the proper one, then install it locally.

    2.Find the powershell v6 from your pc(I'm using win10, just click the "Start" menu -> then you can find powershell v6). Then open it as administrator right -> install the Az.Monitor, version 1.5.0. A screenshot as below:

    enter image description here

    3.Then you can use this command get-help New-AzActionGroupReceiver -Detailed to check if the parameter VoiceCountryCode is available now:

    enter image description here

    4.Then the command you're using can work. And also let me know if you still have more issues.

    Note:

    If you don't install powershell v6 locally, another simple way is that you can use cloud-shell of powershell from azure portal:

    enter image description here