如何使用 cli 创建系统主题
How to create a system topic using cli
我尝试创建一个系统主题。为此,我使用了预览中的 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:
我可以使用传送门查看系统主题
看结果,我更喜欢不使用扩展,所以问题是:How to create a system-topic using the CLI without extension?*
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.
参考文献:
System topics are built-in topics provided by Azure services. You don't see system topics in your Azure subscription because the publisher owns the topics, but you can subscribe to them. To subscribe, you provide information about the resource you want to receive events from. As long as you have access to the resource, you can subscribe to its events.
documentation is clear on this: system topics exist for Azure Services. They are not created, only subscribed to. You can create a custom topics. There are also partner topics that can be created. Event Domains代为创建主题,无需创建主题,这些主题主要用于分区。
更新 2020-06-10:Microsoft 引入了一种显式定义系统主题的方法,而不是使用隐藏的自动生成主题。它不仅可以帮助发现,还可以更好地与整体 Azure 资源体验保持一致。
应该可以使用 Azure CLI 创建系统主题。它将需要使用 az extension add -n eventgrid
安装 EventGrid ARM 扩展。如果它是较早安装的,则需要使用 az extension update -n eventgrid
进行更新。应该更新文档以添加这种细微差别。
目前看来,只能通过 eventgrid
扩展程序手动创建系统主题。
documentation about it is not clear on that point: I created an issue to fix it
列表错误原因:
- 我使用了错误的命令来获取信息:
az eventgrid topic show
应该是 az eventgrid system-topic show
。
- 系统主题没有端点,因为只有系统资源可以在那里发布消息。
- 系统主题没有键,因为只有系统资源可以在那里发布消息。
我尝试创建一个系统主题。为此,我使用了预览中的 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:
我可以使用传送门查看系统主题
看结果,我更喜欢不使用扩展,所以问题是:How to create a system-topic using the CLI without extension?*
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.
参考文献:
System topics are built-in topics provided by Azure services. You don't see system topics in your Azure subscription because the publisher owns the topics, but you can subscribe to them. To subscribe, you provide information about the resource you want to receive events from. As long as you have access to the resource, you can subscribe to its events.
documentation is clear on this: system topics exist for Azure Services. They are not created, only subscribed to. You can create a custom topics. There are also partner topics that can be created. Event Domains代为创建主题,无需创建主题,这些主题主要用于分区。
更新 2020-06-10:Microsoft 引入了一种显式定义系统主题的方法,而不是使用隐藏的自动生成主题。它不仅可以帮助发现,还可以更好地与整体 Azure 资源体验保持一致。
应该可以使用 Azure CLI 创建系统主题。它将需要使用 az extension add -n eventgrid
安装 EventGrid ARM 扩展。如果它是较早安装的,则需要使用 az extension update -n eventgrid
进行更新。应该更新文档以添加这种细微差别。
目前看来,只能通过 eventgrid
扩展程序手动创建系统主题。
documentation about it is not clear on that point: I created an issue to fix it
列表错误原因:
- 我使用了错误的命令来获取信息:
az eventgrid topic show
应该是az eventgrid system-topic show
。 - 系统主题没有端点,因为只有系统资源可以在那里发布消息。
- 系统主题没有键,因为只有系统资源可以在那里发布消息。