Bagikan melalui


Membuat topik kustom Event Grid dengan PowerShell

Skrip ini membuat topik kustom Event Grid.

Catatan

Sebaiknya Anda menggunakan modul Azure Az PowerShell untuk berinteraksi dengan Azure. Untuk memulai, lihat Menginstal Azure PowerShell. Untuk mempelajari cara bermigrasi ke modul Az PowerShell, lihat Memigrasikan Azure PowerShell dari AzureRM ke Az.

Jika Anda tidak memiliki Langganan Azure, buat Akun gratis Azure sebelum memulai.

Sampel skrip

# Give your custom topic a unique name
$myTopic = "<your-custom-topic-name>"

# Provide a name for resource group to create. It will contain the custom event.
$myResourceGroup = "<resource-group-name>"

# Create resource group
New-AzResourceGroup -Name $myResourceGroup -Location westus2

# Create custom topic
New-AzEventGridTopic -ResourceGroupName $myResourceGroup -Name $myTopic -Location westus2 

# Retrieve endpoint and key to use when publishing to the topic
$endpoint = (Get-AzEventGridTopic -ResourceGroupName $myResourceGroup -Name $myTopic).Endpoint
$key = (Get-AzEventGridTopicKey -ResourceGroupName $myResourceGroup -Name $myTopic).Key1

$endpoint
$key

Penjelasan skrip

Skrip ini menggunakan perintah berikut untuk membuat topik kustom. Setiap perintah dalam tabel ditautkan ke dokumentasi spesifik-perintah.

Perintah Catatan
New-AzEventGridTopic Buat topik kustom Event Grid.

Langkah berikutnya