public async Task CanPublishCloudEventToDomain() { EventGridPublisherClientOptions options = InstrumentClientOptions(new EventGridPublisherClientOptions()); EventGridPublisherClient client = InstrumentClient( new EventGridPublisherClient( new Uri(TestEnvironment.CloudEventDomainHost), new AzureKeyCredential(TestEnvironment.CloudEventDomainKey), options)); #region Snippet:CloudNativePublishToDomain CloudEvent cloudEvent = new CloudEvent { Type = "record", // Event Grid does not allow absolute URIs as the domain topic Source = new Uri("test", UriKind.Relative), #if SNIPPET Id = "eventId", Time = DateTimeOffset.Now, #else Id = Recording.Random.NewGuid().ToString(), Time = Recording.Now, #endif Data = new TestPayload("name", 0) }; await client.SendCloudNativeCloudEventAsync(cloudEvent); #endregion }
public async Task SendCloudNativeEvents() { #region Snippet:CloudNativePublish EventGridPublisherClient client = new EventGridPublisherClient( new Uri(TestEnvironment.CloudEventTopicHost), new AzureKeyCredential(TestEnvironment.CloudEventTopicKey)); var cloudEvent = new CloudEvent { Type = "record", Source = new Uri("http://www.contoso.com"), Data = "data" }; await client.SendCloudNativeCloudEventAsync(cloudEvent); #endregion }
public async Task CanPublishSingleCloudEvent() { EventGridPublisherClientOptions options = InstrumentClientOptions(new EventGridPublisherClientOptions()); EventGridPublisherClient client = InstrumentClient( new EventGridPublisherClient( new Uri(TestEnvironment.CloudEventTopicHost), new AzureKeyCredential(TestEnvironment.CloudEventTopicKey), options)); CloudEvent cloudEvent = new CloudEvent { Type = "record", Source = new Uri("http://localHost"), Id = Recording.Random.NewGuid().ToString(), Time = Recording.Now, Data = new TestPayload("name", 0) }; await client.SendCloudNativeCloudEventAsync(cloudEvent); }