Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Det här skriptet skapar en Event Grid-prenumeration på händelserna för ett Blob Storage-konto.
Anmärkning
Vi rekommenderar att du använder Azure Az PowerShell-modulen för att interagera med Azure. Se Installera Azure PowerShell för att komma igång. För att lära dig hur du migrerar till Az PowerShell-modulen, se Migrera Azure PowerShell från AzureRM till Az.
Om du inte har något Azure-konto skapar du ett kostnadsfritt konto innan du börjar.
Exempelskript – stabilt
# 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
Förklaring av skript
Det här skriptet använder följande kommandon för att skapa händelseprenumerationen. Varje kommando i tabellen länkar till kommandospecifik dokumentation.
| Befallning | Noteringar |
|---|---|
| New-AzEventGridSubscription | Skapa en Event Grid-prenumeration. |
Nästa steg
- En introduktion till hanterade program finns i Azure Managed Application overview (Översikt över Azure Managed Application).
- Mer information om PowerShell finns i Azure PowerShell-dokumentationen.