Delen via


Abonneren op gebeurtenissen voor een Blob Storage-account met PowerShell

Met dit script maakt u een Event Grid-abonnement op de gebeurtenissen voor een Blob Storage-account.

Opmerking

We raden u aan om de Azure Az PowerShell-module te gebruiken om met Azure te communiceren. Zie Azure PowerShell installeren om aan de slag te gaan. Om te leren hoe u naar de Az PowerShell-module kunt migreren, zie Migrate Azure PowerShell from AzureRM to Az.

Als u geen Azure-account hebt, maak dan een gratis account aan voordat u begint.

Voorbeeldscript - stabiel

# 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

Uitleg van script

In dit script wordt de volgende opdracht gebruikt om het abonnement op de gebeurtenis te maken. Elke opdracht in de tabel linkt naar documentatie die specifiek is voor die opdracht.

Opdracht Opmerkingen
New-AzEventGridSubscription Hiermee wordt een Event Grid-abonnement gemaakt.

Volgende stappen