0
votes

I have elected to leverage Azure Event Grid in an enterprise multi-tenant model application. I also want to use Cloud Events instead of the proprietary AEG format. I am using AEG domains for each tenant and then I want a custom topic and subject for my messages. The v0.1 of cloud events had a "#" delimited property for cloud events topic and subjects. It looks like V1.0 does not anymore? It really is not clear in the Azure docs.

Secondarily, with Azure Event Grid Domains it seems you can only create a Domain Topic via Powershell (https://docs.microsoft.com/en-us/cli/azure/eventgrid/domain/topic?view=azure-cli-latest) and not in the portal. I can't find a clear way to create a topic for an event domain any other way.

My topic is currently set to : /providers/Microsoft.EventGrid/domains/{tenantname}/topics/refresh. Do domain topics just appear once they're published for the first time?

Any insight on the format of the cloud events schema and managing topics would be great!

1

1 Answers

0
votes

So I now see the UI for this in Azure Portal. You simply, add an event subscription on the domain and one of the options is to filer by topic, where you add your topics.

https://docs.microsoft.com/bs-latn-ba/azure/event-grid/how-to-event-domains?tabs=azurecli#create-topics-and-subscriptions

It is clear here that "There's no separate step to create a topic in a domain.".

Secondarily, I was able to set source = topic for Cloud Events v1.0 and separate out subject as well. Here is my CloudEvent generic class :

public class CloudEvent<T> where T : class
    {
        [JsonProperty("id")]
        public string EventId
        {
            protected set { }
            get => Guid.NewGuid().ToString();
        }

        [JsonProperty("specversion")]
        public string CloudEventVersion
        {
            protected set { }
            get => "1.0";
        }

        [JsonProperty("type")]
        public string EventType { get; set; }

        [JsonProperty("eventTypeVersion")]
        public string EventTypeVersion
        {
            protected set { }
            get => "1.0";
        }

        [JsonProperty("source")]
        public string Source { get; set; }

        [JsonProperty("subject")]
        public string Subject { get; set; }

        [JsonProperty("time")]
        public string Time
        {
            protected set { }
            get => DateTime.UtcNow.ToString(CultureInfo.InvariantCulture);
        }

        [JsonProperty("data")]
        public T Data { get; set; }

    }

My topic (which is set to source property for cloud events) is :

/resourceGroups/{rgname}/providers/Microsoft.EventGrid/domains/{domainname}/topics/{topic}

I think this would also set subject properly according to this schema.

https://docs.microsoft.com/en-us/azure/event-grid/cloudevents-schema