【问题标题】:How to create a system topic using cli如何使用 cli 创建系统主题
【发布时间】:2020-06-11 05:37:41
【问题描述】:

我尝试创建一个系统主题。为此,我正在使用预览中的 eventgrid 扩展。

az eventgrid system-topic create \
    --name $topicName \
    --resource-group $resourceGroupName \
    --location $location \
    --topic-type microsoft.storage.storageaccounts \
    --source $storageId

但如果我尝试以这种方式获取 id/endpoint/key:

echo "Landing Topic Information:"
topicId=$(az eventgrid topic show \
  --name $topicName \
  --resource-group $resourceGroupName \
  --query id \
  --output tsv)
echo "Topic Id: $topicId"

topicEndpoint=$(az eventgrid topic show \
  --name $topicName \
  --resource-group $resourceGroupName \
  --query endpoint \
  --output tsv)
echo "Topic Endpoint: $topicEndpoint"

topicKey=$(az eventgrid topic key list \
  --name $topicName \
  --resource-group $resourceGroupName \
  --query key1 \
  --output tsv)
echo "Topic Key: $topicKey"

我收到一个错误:

Landing Topic Information:
The behavior of this command has been altered by the following extension: eventgrid
The Resource 'Microsoft.EventGrid/topics/xxx' under resource group 'xxxxxx-grp' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
Topic Id: 
The behavior of this command has been altered by the following extension: eventgrid
The Resource 'Microsoft.EventGrid/topics/xxx' under resource group 'xxxxxx-grp' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
Topic Endpoint: 
The behavior of this command has been altered by the following extension: eventgrid
The Resource 'Microsoft.EventGrid/topics/xxx' under resource group 'xxxxxx-grp' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
Topic Key: 

我可以使用门户查看系统主题

看结果,我更喜欢不使用扩展,所以问题是:如何在没有扩展的情况下使用 CLI 创建系统主题?*

命令行界面:

$ az --version
azure-cli                          2.7.0

command-modules-nspkg              2.0.3
core                               2.7.0
nspkg                              3.0.4
telemetry                          1.0.4

Extensions:
eventgrid                          0.4.9
interactive                        0.4.4

Python location '/opt/az/bin/python3'
Extensions directory '/home/angelcc/.azure/cliextensions'

Python (Linux) 3.6.10 (default, May 29 2020, 08:10:59) 
[GCC 9.3.0]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date.

参考资料:

【问题讨论】:

    标签: azure-cli azure-eventgrid


    【解决方案1】:

    系统主题是 Azure 服务提供的内置主题。你在 Azure 订阅中看不到系统主题,因为发布者拥有这些主题,但你可以订阅它们。要订阅,您需要提供有关要从中接收事件的资源的信息。只要您有权访问该资源,就可以订阅其事件。

    documentation 对此很清楚:Azure 服务存在系统主题。它们不是创建的,只是订阅的。您可以创建一个custom topics。还有可以创建的partner topicsEvent Domains 代表您创建主题,无需创建主题,这些主题主要用于分区。

    2020-06-10 更新:Microsoft 引入了一种明确定义系统主题的方法,而不是使用隐藏的自动生成主题。它应该不仅有助于提高可发现性,而且还能更好地与整体 Azure 资源体验保持一致。

    应该可以使用 Azure CLI 创建系统主题。它将需要使用 az extension add -n eventgrid 安装 EventGrid ARM 扩展。如果它是较早安装的,则需要使用az extension update -n eventgrid 进行更新。应更新文档以添加此细微差别。

    【讨论】:

    • 我不明白。系统主题是内置的,但正如您在System topics documentation 中所读到的,描述的两种方法之一是手动创建主题然后创建订阅。如文档所述,如果您不手动创建主题,它将在最后一次订阅消失后自动删除。
    • 您可以在Create, view, and manage Event Grid system topics using Azure CLI 中阅读有关如何创建系统主题的更多信息。问题是它在没有扩展的情况下不起作用,即使文档与任何扩展都不相关。 :)
    • 需要事件网格资源提供程序扩展是有道理的。我希望将其视为本文的先决条件。我必须对此进行审查。
    • 我创建了一张票。我认为重要的是说它是 CLI 预览功能,当它是门户中的一个选项时。 github.com/MicrosoftDocs/azure-docs/issues/56777
    【解决方案2】:

    目前看来,只能通过eventgrid扩展手动创建系统主题。

    documentation 关于这一点尚不清楚:I created an issue to fix it

    错误列表的原因:

    • 我使用了错误的命令来获取信息:az eventgrid topic show 应该是 az eventgrid system-topic show
    • 系统主题没有端点,因为只有系统资源可以在那里发布消息。
    • 系统主题没有,因为只有系统资源可以在那里发布消息。

    【讨论】:

    猜你喜欢
    • 2022-01-06
    • 1970-01-01
    • 2019-02-09
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-10
    • 1970-01-01
    相关资源
    最近更新 更多