Feliratkozás Blob Storage-fiók eseményeire a PowerShell-lel

Ez a szkript létrehoz egy Event Grid-előfizetést egy Blob Storage-fiók eseményeihez.

Megjegyzés:

Javasoljuk az Azure Az PowerShell modult használni az Azure-val való interakcióhoz. Az első lépésekhez tekintse meg Az Azure PowerShell telepítése témakört. Az Az PowerShell-modulba való migrálásról további információt az Azure PowerShell migrálása az AzureRM-ből az Az-be című témakörben talál.

Ha még nem rendelkezik Azure-fiókkal, első lépésként hozzon létre egy ingyenes fiókot.

Példaszkript – 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

Szkript ismertetése

A szkript a következő parancsot használja az esemény-előfizetés létrehozásához. A táblázatban lévő összes parancs a hozzá tartozó dokumentációra hivatkozik.

Parancs Jegyzetek
New-AzEventGridSubscription Event Grid-előfizetés létrehozása.

Következő lépések