示例#1
0
        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 CanPublishSingleCloudEvent()
        {
            EventGridPublisherClientOptions options = InstrumentClientOptions(new EventGridPublisherClientOptions());
            EventGridPublisherClient        client  = InstrumentClient(
                new EventGridPublisherClient(
                    new Uri(TestEnvironment.CloudEventTopicHost),
                    new AzureKeyCredential(TestEnvironment.CloudEventTopicKey),
                    options));

            CloudEvent cloudEvent =
                new CloudEvent(
                    "record",
                    new Uri("http://localHost"),
                    Recording.Random.NewGuid().ToString(),
                    Recording.Now.DateTime)
            {
                Data = new TestPayload("name", 0)
            };

            await client.SendCloudEventAsync(cloudEvent);
        }
 public static System.Threading.Tasks.Task <Azure.Response> SendCloudNativeCloudEventAsync(this Azure.Messaging.EventGrid.EventGridPublisherClient client, CloudNative.CloudEvents.CloudEvent cloudEvent, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     throw null;
 }