此指令碼可建立 Event Grid 自訂主題。
附註
建議您使用 Azure Az PowerShell 模組來與 Azure 互動。 若要開始使用,請參閱安裝 Azure PowerShell。 若要了解如何遷移至 Az PowerShell 模組,請參閱將 Azure PowerShell 從 AzureRM 移轉至 Az。
如果您沒有 Azure 帳戶,請在開始之前建立 免費帳戶 。
範例指令碼
# 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
指令碼說明
此指令碼會使用下列命令來建立自訂主題。 下表中的每個命令都會連結至命令特定的文件。
| Command | 注意 |
|---|---|
| New-AzEventGridTopic | 建立 Event Grid 自訂主題。 |
後續步驟
- 如需受控應用程式的簡介,請參閱 Azure 受控應用程式概觀。
- 如需 PowerShell 的詳細資訊,請參閱 Azure PowerShell 文件。