Berlangganan ke peristiwa untuk akun penyimpanan Blob dengan PowerShell
Skrip ini membuat langganan Event Grid ke acara untuk akun penyimpanan Blob.
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.
Skrip sampel - stabil
# Provide a unique name for the Blob storage account.
$storageName = "<your-unique-storage-name>"
# Provide an endpoint for handling the events. Must be formatted "https://your-endpoint-URL"
$myEndpoint = "<your-endpoint-URL>"
# Provide the name of the resource group to create. It will contain the storage account.
$myResourceGroup="<resource-group-name>"
# Create resource group
New-AzResourceGroup -Name $myResourceGroup -Location westus2
# Create the Blob storage account.
New-AzStorageAccount -ResourceGroupName $myResourceGroup `
-Name $storageName `
-Location westus2 `
-SkuName Standard_LRS `
-Kind BlobStorage `
-AccessTier Hot
# Get the resource ID of the Blob storage account.
$storageId = (Get-AzStorageAccount -ResourceGroupName $myResourceGroup -AccountName $storageName).Id
# Subscribe to the Blob storage account.
New-AzEventGridSubscription `
-EventSubscriptionName demoSubToStorage `
-Endpoint $myEndpoint `
-ResourceId $storageId
Penjelasan skrip
Skrip ini menggunakan perintah berikut untuk membuat langganan peristiwa. Setiap perintah dalam tabel ditautkan ke dokumentasi spesifik-perintah.
Perintah | Catatan |
---|---|
New-AzEventGridSubscription | Membuat langganan Event Grid. |
Langkah berikutnya
- Untuk pengenalan aplikasi terkelola, lihat Ringkasan Azure Managed Application.
- Untuk informasi selengkapnya tentang PowerShell, lihat Dokumentasi Azure PowerShell.