Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Azure Action Groups are essential components in Azure Monitor and Azure Alerts. They define a collection of notification preferences and actions that are used by both Azure Monitor and service alerts. While "New-AzActionGroup" is a cmdlet from the Azure PowerShell module and not a native Windows command, it can be used effectively within a Windows environment to manage Azure resources. This article will guide you through creating and managing Azure Action Groups using PowerShell on a Windows system.
Before you begin, ensure you have the following:
Install-Module -Name Az -AllowClobber -Scope CurrentUser
First, you need to connect to your Azure account using the Connect-AzAccount
cmdlet:
Connect-AzAccount
You can create an action group using the New-AzActionGroup
cmdlet. Below is an example of how to create an action group with an email receiver.
# Define variables
$resourceGroupName = "MyResourceGroup"
$actionGroupName = "MyActionGroup"
$receiverName = "MyEmailReceiver"
$emailAddress = "user@example.com"
# Create the action group
New-AzActionGroup -ResourceGroupName $resourceGroupName -Name $actionGroupName -ShortName "MyAG" -Receiver `
@{ Name = $receiverName; EmailAddress = $emailAddress; Type = "Email" }
You can add different types of receivers to the action group, such as SMS, Webhook, or ITSM. Here’s an example of adding an SMS receiver:
# Define additional receiver
$smsReceiverName = "MySMSReceiver"
$countryCode = "1" # Country code for the phone number
$phoneNumber = "1234567890"
# Add the SMS receiver to the action group
Add-AzActionGroupReceiver -ResourceGroupName $resourceGroupName -Name $actionGroupName -Receiver `
@{ Name = $smsReceiverName; CountryCode = $countryCode; PhoneNumber = $phoneNumber; Type = "SMS" }
To verify that your action group has been created and to list its details, use the Get-AzActionGroup
cmdlet:
# Retrieve the action group details
$actionGroup = Get-AzActionGroup -ResourceGroupName $resourceGroupName -Name $actionGroupName
$actionGroup.Receivers
You can update, remove, or list action groups using respective cmdlets. Here are some examples:
To update an existing action group, for example, to change the email address of an email receiver:
# Update the email receiver
Set-AzActionGroup -ResourceGroupName $resourceGroupName -Name $actionGroupName -Receiver `
@{ Name = $receiverName; EmailAddress = "newemail@example.com"; Type = "Email" }
To remove an action group, use the Remove-AzActionGroup
cmdlet:
# Remove the action group
Remove-AzActionGroup -ResourceGroupName $resourceGroupName -Name $actionGroupName
Creating and managing Azure Action Groups using PowerShell on a Windows environment is a straightforward process. With the New-AzActionGroup
cmdlet, you can easily define and manage notification preferences and actions for your Azure resources.