The domain topic can be created using the following APIs:
Domain Topics - Create Or Update
for example:
https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.EventGrid/domains/myDomain/topics/myTopicXXX?api-version=2020-01-01-preview
the payload is empty: {}
Event Subscriptions - Create Or Update
for example:
https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.EventGrid/domains/myDomain/topics/myTopic/providers/Microsoft.EventGrid/eventSubscriptions/mySubscription?api-version=2020-01-01-preview
Example of the payload:
{
"properties":{
"destination":{
"endpointType":"HybridConnection",
"properties":{
"resourceId":"<myHybridConnectionresourceId>"
}
},
"filter":{
"isSubjectCaseSensitive":false,
"subjectBeginsWith":null,
"subjectEndsWith":null
},
"labels":[],
"eventDeliverySchema":"EventGridSchema",
"retryPolicy":{
"maxDeliveryAttempts":3,
"eventTimeToLiveInMinutes":1440
}
}
}
In this case, the domain topic will be created automatically when doesn't exist it.
Note, that this is a great feature allows to create a topic from the subscriber side.
Btw. have a look at my Azure Event Grid Tools, it is built on the REST APIs.