获取事件网格资源(主题或域)的访问密钥Get access keys for Event Grid resources (topics or domains)

访问密钥用于对将事件发布到 Azure 事件网格资源(主题和域)的应用程序进行身份验证。Access keys are used to authenticate an application publishing events to Azure Event Grid resources (topics and domains). 我们建议定期重新生成密钥并安全地存储它们。We recommend regenerating your keys regularly and storing them securely. 你拥有两个访问密钥,因此,在重新生成其中一个密钥时,可以使用另一个密钥来保持连接。You are provided with two access keys so that you can maintain connections using one key while regenerating the other.

本文介绍如何使用 Azure 门户、PowerShell 或 CLI 获取事件网格资源(主题或域)的访问密钥。This article describes how to get access keys for an Event Grid resource (topic or domain) using Azure portal, PowerShell, or CLI.

Azure 门户Azure portal

在 Azure 门户中,切换到主题或域的“事件网格主题”或“事件网格域”页的“访问密钥”选项卡。In the Azure portal, switch to Access keys tab of the Event Grid Topic or Event Grid Domain page for your topic or domain.

“访问密钥”页

Azure PowerShellAzure PowerShell

使用 Get-AzEventGridTopicKey 命令获取主题的访问密钥。Use the Get-AzEventGridTopicKey command to get access keys for topics.

Get-AzEventGridTopicKey -ResourceGroup <RESOURCE GROUP NAME> -Name <TOPIC NAME>

使用 Get-AzEventGridDomainKey 命令获取域的访问密钥。Use Get-AzEventGridDomainKey command to get access keys for domains.

Get-AzEventGridDomainKey -ResourceGroup <RESOURCE GROUP NAME> -Name <DOMAIN NAME>

Azure CLIAzure CLI

使用 az eventgrid topic key list 获取主题的访问密钥。Use the az eventgrid topic key list to get access keys for topics.

az eventgrid topic key list --resource-group <RESOURCE GROUP NAME> --name <TOPIC NAME>

使用 az eventgrid domain key list 获取域的访问密钥。Use az eventgrid domain key list to get access keys for domains.

az eventgrid domain key list --resource-group <RESOURCE GROUP NAME> --name <DOMAIN NAME>

后续步骤Next steps

请参阅以下文章:对发布客户端进行身份验证See the following article: Authenticate publishing clients.