From 94b63b180524beaa660764ebe90b12a5f18dcd90 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Thu, 28 Jan 2021 19:28:16 -0800 Subject: [PATCH 1/3] EG API updates --- .../Azure.Messaging.EventGrid/README.md | 10 +- ...zure.Messaging.EventGrid.netstandard2.0.cs | 212 +++++++++--------- .../samples/Sample1_PublishEventsToTopic.md | 4 +- .../samples/Sample2_PublishEventsToDomain.md | 4 +- .../Sample3_ParseAndDeserializeEvents.md | 2 +- .../src/Azure.Messaging.EventGrid.csproj | 3 + .../src/Customization/EventGridEvent.cs | 5 +- .../Customization/EventGridPublisherClient.cs | 47 +--- .../src/Customization/EventGridSasBuilder.cs | 91 ++++++++ .../Customization/SystemEventExtensions.cs | 194 ++++++++-------- ...emEventMappings.cs => SystemEventNames.cs} | 196 ++++++++-------- .../tests/ConsumeEventTests.cs | 28 +-- .../tests/EventGridClientLiveTests.cs | 18 +- .../tests/EventGridEventTests.cs | 14 +- .../Sample1_SendEventsToTopicAndDomain.cs | 8 +- .../Sample2_ParseAndDeserializeEvents.cs | 2 +- 16 files changed, 448 insertions(+), 390 deletions(-) create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridSasBuilder.cs rename sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/{SystemEventMappings.cs => SystemEventNames.cs} (73%) diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/README.md b/sdk/eventgrid/Azure.Messaging.EventGrid/README.md index 02150d4d20bf..1cfe4ef23167 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/README.md +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/README.md @@ -96,10 +96,10 @@ Publishing events to Event Grid is performed using the `EventGridPublisherClient List eventsList = new List { new EventGridEvent( - "This is the event data", "ExampleEventSubject", "Example.EventType", - "1.0") + "1.0", + "This is the event data") }; // Send the events @@ -138,10 +138,10 @@ To publish events to any topic in an Event Domain, push the events to the domain List eventsList = new List { new EventGridEvent( - "This is the event data", "ExampleEventSubject", "Example.EventType", - "1.0") + "1.0", + "This is the event data") { Topic = "MyTopic" } @@ -185,7 +185,7 @@ foreach (CloudEvent cloudEvent in cloudEvents) TestPayload testPayload = await cloudEvent.GetDataAsync(myCustomSerializer); Console.WriteLine(testPayload.Name); break; - case SystemEventMappings.StorageBlobDeletedEventName: + case SystemEventNames.StorageBlobDeleted: // Example for deserializing system events using GetData StorageBlobDeletedEventData blobDeleted = cloudEvent.GetData(); Console.WriteLine(blobDeleted.BlobType); diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs index 63f8f83328f1..35fe266c0de6 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs @@ -28,7 +28,7 @@ public CloudEvent(string source, string type, object data, string dataContentTyp } public partial class EventGridEvent { - public EventGridEvent(object data, string subject, string eventType, string dataVersion, System.Type dataSerializationType = null) { } + public EventGridEvent(string subject, string eventType, string dataVersion, object data, System.Type dataSerializationType = null) { } public string DataVersion { get { throw null; } set { } } public System.DateTimeOffset EventTime { get { throw null; } set { } } public string EventType { get { throw null; } set { } } @@ -50,9 +50,7 @@ public partial class EventGridPublisherClient protected EventGridPublisherClient() { } public EventGridPublisherClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { } public EventGridPublisherClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.Messaging.EventGrid.EventGridPublisherClientOptions options) { } - public EventGridPublisherClient(System.Uri endpoint, Azure.AzureSasCredential credential) { } - public EventGridPublisherClient(System.Uri endpoint, Azure.AzureSasCredential credential, Azure.Messaging.EventGrid.EventGridPublisherClientOptions options) { } - public static string BuildSharedAccessSignature(System.Uri endpoint, System.DateTimeOffset expirationUtc, Azure.AzureKeyCredential key, Azure.Messaging.EventGrid.EventGridPublisherClientOptions.ServiceVersion apiVersion = Azure.Messaging.EventGrid.EventGridPublisherClientOptions.ServiceVersion.V2018_01_01) { throw null; } + public EventGridPublisherClient(System.Uri endpoint, Azure.AzureSasCredential credential, Azure.Messaging.EventGrid.EventGridPublisherClientOptions options = null) { } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public virtual Azure.Response SendEncodedCloudEvents(System.ReadOnlyMemory cloudEvents, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] @@ -73,105 +71,113 @@ public enum ServiceVersion V2018_01_01 = 1, } } - public static partial class SystemEventMappings - { - public const string ACSChatMemberAddedToThreadWithUserEventName = "Microsoft.Communication.ChatMemberAddedToThreadWithUser"; - public const string ACSChatMemberRemovedFromThreadWithUserEventName = "Microsoft.Communication.ChatMemberRemovedFromThreadWithUser"; - public const string ACSChatMessageDeletedEventName = "Microsoft.Communication.ChatMessageDeleted"; - public const string ACSChatMessageEditedEventName = "Microsoft.Communication.ChatMessageEdited"; - public const string ACSChatMessageReceivedEventName = "Microsoft.Communication.ChatMessageReceived"; - public const string ACSChatThreadCreatedWithUserEventName = "Microsoft.Communication.ChatThreadCreatedWithUser"; - public const string ACSChatThreadPropertiesUpdatedPerUserEventName = "Microsoft.Communication.ChatThreadPropertiesUpdatedPerUser"; - public const string ACSChatThreadWithUserDeletedEventName = "Microsoft.Communication.ChatThreadWithUserDeleted"; - public const string ACSSMSDeliveryReportReceivedEventName = "Microsoft.Communication.SMSDeliveryReportReceived"; - public const string ACSSMSReceivedEventName = "Microsoft.Communication.SMSReceived"; - public const string AppConfigurationKeyValueDeletedEventName = "Microsoft.AppConfiguration.KeyValueDeleted"; - public const string AppConfigurationKeyValueModifiedEventName = "Microsoft.AppConfiguration.KeyValueModified"; - public const string ContainerRegistryChartDeletedEventName = "Microsoft.ContainerRegistry.ChartDeleted"; - public const string ContainerRegistryChartPushedEventName = "Microsoft.ContainerRegistry.ChartPushed"; - public const string ContainerRegistryImageDeletedEventName = "Microsoft.ContainerRegistry.ImageDeleted"; - public const string ContainerRegistryImagePushedEventName = "Microsoft.ContainerRegistry.ImagePushed"; - public const string EventGridSubscriptionDeletedEventName = "Microsoft.EventGrid.SubscriptionDeletedEvent"; - public const string EventGridSubscriptionValidationEventName = "Microsoft.EventGrid.SubscriptionValidationEvent"; - public const string EventHubCaptureFileCreatedEventName = "Microsoft.EventHub.CaptureFileCreated"; - public const string IoTHubDeviceConnectedEventName = "Microsoft.Devices.DeviceConnected"; - public const string IoTHubDeviceCreatedEventName = "Microsoft.Devices.DeviceCreated"; - public const string IoTHubDeviceDeletedEventName = "Microsoft.Devices.DeviceDeleted"; - public const string IoTHubDeviceDisconnectedEventName = "Microsoft.Devices.DeviceDisconnected"; - public const string IotHubDeviceTelemetryEventName = "Microsoft.Devices.DeviceTelemetry"; - public const string KeyVaultAccessPolicyChangedEventName = "Microsoft.KeyVault.VaultAccessPolicyChanged"; - public const string KeyVaultCertificateExpiredEventName = "Microsoft.KeyVault.CertificateExpired"; - public const string KeyVaultCertificateNearExpiryEventName = "Microsoft.KeyVault.CertificateNearExpiry"; - public const string KeyVaultCertificateNewVersionCreatedEventName = "Microsoft.KeyVault.CertificateNewVersionCreated"; - public const string KeyVaultKeyExpiredEventName = "Microsoft.KeyVault.KeyExpired"; - public const string KeyVaultKeyNearExpiryEventName = "Microsoft.KeyVault.KeyNearExpiry"; - public const string KeyVaultKeyNewVersionCreatedEventName = "Microsoft.KeyVault.KeyNewVersionCreated"; - public const string KeyVaultSecretExpiredEventName = "Microsoft.KeyVault.SecretExpired"; - public const string KeyVaultSecretNearExpiryEventName = "Microsoft.KeyVault.SecretNearExpiry"; - public const string KeyVaultSecretNewVersionCreatedEventName = "Microsoft.KeyVault.SecretNewVersionCreated"; - public const string MachineLearningServicesDatasetDriftDetectedEventName = "Microsoft.MachineLearningServices.DatasetDriftDetected"; - public const string MachineLearningServicesModelDeployedEventName = "Microsoft.MachineLearningServices.ModelDeployed"; - public const string MachineLearningServicesModelRegisteredEventName = "Microsoft.MachineLearningServices.ModelRegistered"; - public const string MachineLearningServicesRunCompletedEventName = "Microsoft.MachineLearningServices.RunCompleted"; - public const string MachineLearningServicesRunStatusChangedEventName = "Microsoft.MachineLearningServices.RunStatusChanged"; - public const string MapsGeofenceEnteredEventName = "Microsoft.Maps.GeofenceEntered"; - public const string MapsGeofenceExitedEventName = "Microsoft.Maps.GeofenceExited"; - public const string MapsGeofenceResultEventName = "Microsoft.Maps.GeofenceResult"; - public const string MediaJobCanceledEventName = "Microsoft.Media.JobCanceled"; - public const string MediaJobCancelingEventName = "Microsoft.Media.JobCanceling"; - public const string MediaJobErroredEventName = "Microsoft.Media.JobErrored"; - public const string MediaJobFinishedEventName = "Microsoft.Media.JobFinished"; - public const string MediaJobOutputCanceledEventName = "Microsoft.Media.JobOutputCanceled"; - public const string MediaJobOutputCancelingEventName = "Microsoft.Media.JobOutputCanceling"; - public const string MediaJobOutputErroredEventName = "Microsoft.Media.JobOutputErrored"; - public const string MediaJobOutputFinishedEventName = "Microsoft.Media.JobOutputFinished"; - public const string MediaJobOutputProcessingEventName = "Microsoft.Media.JobOutputProcessing"; - public const string MediaJobOutputProgressEventName = "Microsoft.Media.JobOutputProgress"; - public const string MediaJobOutputScheduledEventName = "Microsoft.Media.JobOutputScheduled"; - public const string MediaJobOutputStateChangeEventName = "Microsoft.Media.JobOutputStateChange"; - public const string MediaJobProcessingEventName = "Microsoft.Media.JobProcessing"; - public const string MediaJobScheduledEventName = "Microsoft.Media.JobScheduled"; - public const string MediaJobStateChangeEventName = "Microsoft.Media.JobStateChange"; - public const string MediaLiveEventConnectionRejectedEventName = "Microsoft.Media.LiveEventConnectionRejected"; - public const string MediaLiveEventEncoderConnectedEventName = "Microsoft.Media.LiveEventEncoderConnected"; - public const string MediaLiveEventEncoderDisconnectedEventName = "Microsoft.Media.LiveEventEncoderDisconnected"; - public const string MediaLiveEventIncomingDataChunkDroppedEventName = "Microsoft.Media.LiveEventIncomingDataChunkDropped"; - public const string MediaLiveEventIncomingStreamReceivedEventName = "Microsoft.Media.LiveEventIncomingStreamReceived"; - public const string MediaLiveEventIncomingStreamsOutOfSyncEventName = "Microsoft.Media.LiveEventIncomingStreamsOutOfSync"; - public const string MediaLiveEventIncomingVideoStreamsOutOfSyncEventName = "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync"; - public const string MediaLiveEventIngestHeartbeatEventName = "Microsoft.Media.LiveEventIngestHeartbeat"; - public const string MediaLiveEventTrackDiscontinuityDetectedEventName = "Microsoft.Media.LiveEventTrackDiscontinuityDetected"; - public const string ResourceActionCancelEventName = "Microsoft.Resources.ResourceActionCancel"; - public const string ResourceActionFailureEventName = "Microsoft.Resources.ResourceActionFailure"; - public const string ResourceActionSuccessEventName = "Microsoft.Resources.ResourceActionSuccess"; - public const string ResourceDeleteCancelEventName = "Microsoft.Resources.ResourceDeleteCancel"; - public const string ResourceDeleteFailureEventName = "Microsoft.Resources.ResourceDeleteFailure"; - public const string ResourceDeleteSuccessEventName = "Microsoft.Resources.ResourceDeleteSuccess"; - public const string ResourceWriteCancelEventName = "Microsoft.Resources.ResourceWriteCancel"; - public const string ResourceWriteFailureEventName = "Microsoft.Resources.ResourceWriteFailure"; - public const string ResourceWriteSuccessEventName = "Microsoft.Resources.ResourceWriteSuccess"; - public const string ServiceBusActiveMessagesAvailableWithNoListenersEventName = "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners"; - public const string ServiceBusDeadletterMessagesAvailableWithNoListenerEventName = "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener"; - public const string StorageBlobCreatedEventName = "Microsoft.Storage.BlobCreated"; - public const string StorageBlobDeletedEventName = "Microsoft.Storage.BlobDeleted"; - public const string StorageBlobRenamedEventName = "Microsoft.Storage.BlobRenamed"; - public const string StorageDirectoryCreatedEventName = "Microsoft.Storage.DirectoryCreated"; - public const string StorageDirectoryDeletedEventName = "Microsoft.Storage.DirectoryDeleted"; - public const string StorageDirectoryRenamedEventName = "Microsoft.Storage.DirectoryRenamed"; - public const string StorageLifecyclePolicyCompletedEventName = "Microsoft.Storage.LifecyclePolicyCompleted"; - public const string WebAppServicePlanUpdatedEventName = "Microsoft.Web.AppServicePlanUpdated"; - public const string WebAppUpdatedEventName = "Microsoft.Web.AppUpdated"; - public const string WebBackupOperationCompletedEventName = "Microsoft.Web.BackupOperationCompleted"; - public const string WebBackupOperationFailedEventName = "Microsoft.Web.BackupOperationFailed"; - public const string WebBackupOperationStartedEventName = "Microsoft.Web.BackupOperationStarted"; - public const string WebRestoreOperationCompletedEventName = "Microsoft.Web.RestoreOperationCompleted"; - public const string WebRestoreOperationFailedEventName = "Microsoft.Web.RestoreOperationFailed"; - public const string WebRestoreOperationStartedEventName = "Microsoft.Web.RestoreOperationStarted"; - public const string WebSlotSwapCompletedEventName = "Microsoft.Web.SlotSwapCompleted"; - public const string WebSlotSwapFailedEventName = "Microsoft.Web.SlotSwapFailed"; - public const string WebSlotSwapStartedEventName = "Microsoft.Web.SlotSwapStarted"; - public const string WebSlotSwapWithPreviewCancelledEventName = "Microsoft.Web.SlotSwapWithPreviewCancelled"; - public const string WebSlotSwapWithPreviewStartedEventName = "Microsoft.Web.SlotSwapWithPreviewStarted"; + public partial class EventGridSasBuilder + { + public EventGridSasBuilder(System.Uri endpoint, System.DateTimeOffset expiresOn) { } + public Azure.Messaging.EventGrid.EventGridPublisherClientOptions.ServiceVersion ApiVersion { get { throw null; } set { } } + public System.Uri Endpoint { get { throw null; } set { } } + public System.DateTimeOffset ExpiresOn { get { throw null; } set { } } + public string GenerateSas(Azure.AzureKeyCredential key) { throw null; } + } + public static partial class SystemEventNames + { + public const string ACSChatMemberAddedToThreadWithUser = "Microsoft.Communication.ChatMemberAddedToThreadWithUser"; + public const string ACSChatMemberRemovedFromThreadWithUser = "Microsoft.Communication.ChatMemberRemovedFromThreadWithUser"; + public const string ACSChatMessageDeleted = "Microsoft.Communication.ChatMessageDeleted"; + public const string ACSChatMessageEdited = "Microsoft.Communication.ChatMessageEdited"; + public const string ACSChatMessageReceived = "Microsoft.Communication.ChatMessageReceived"; + public const string ACSChatThreadCreatedWithUser = "Microsoft.Communication.ChatThreadCreatedWithUser"; + public const string ACSChatThreadPropertiesUpdatedPerUser = "Microsoft.Communication.ChatThreadPropertiesUpdatedPerUser"; + public const string ACSChatThreadWithUserDeleted = "Microsoft.Communication.ChatThreadWithUserDeleted"; + public const string ACSSMSDeliveryReportReceived = "Microsoft.Communication.SMSDeliveryReportReceived"; + public const string ACSSMSReceived = "Microsoft.Communication.SMSReceived"; + public const string AppConfigurationKeyValueDeleted = "Microsoft.AppConfiguration.KeyValueDeleted"; + public const string AppConfigurationKeyValueModified = "Microsoft.AppConfiguration.KeyValueModified"; + public const string ContainerRegistryChartDeleted = "Microsoft.ContainerRegistry.ChartDeleted"; + public const string ContainerRegistryChartPushed = "Microsoft.ContainerRegistry.ChartPushed"; + public const string ContainerRegistryImageDeleted = "Microsoft.ContainerRegistry.ImageDeleted"; + public const string ContainerRegistryImagePushed = "Microsoft.ContainerRegistry.ImagePushed"; + public const string EventGridSubscriptionDeleted = "Microsoft.EventGrid.SubscriptionDeletedEvent"; + public const string EventGridSubscriptionValidation = "Microsoft.EventGrid.SubscriptionValidationEvent"; + public const string EventHubCaptureFileCreated = "Microsoft.EventHub.CaptureFileCreated"; + public const string IoTHubDeviceConnected = "Microsoft.Devices.DeviceConnected"; + public const string IoTHubDeviceCreated = "Microsoft.Devices.DeviceCreated"; + public const string IoTHubDeviceDeleted = "Microsoft.Devices.DeviceDeleted"; + public const string IoTHubDeviceDisconnected = "Microsoft.Devices.DeviceDisconnected"; + public const string IotHubDeviceTelemetry = "Microsoft.Devices.DeviceTelemetry"; + public const string KeyVaultAccessPolicyChanged = "Microsoft.KeyVault.VaultAccessPolicyChanged"; + public const string KeyVaultCertificateExpired = "Microsoft.KeyVault.CertificateExpired"; + public const string KeyVaultCertificateNearExpiry = "Microsoft.KeyVault.CertificateNearExpiry"; + public const string KeyVaultCertificateNewVersionCreated = "Microsoft.KeyVault.CertificateNewVersionCreated"; + public const string KeyVaultKeyExpired = "Microsoft.KeyVault.KeyExpired"; + public const string KeyVaultKeyNearExpiry = "Microsoft.KeyVault.KeyNearExpiry"; + public const string KeyVaultKeyNewVersionCreated = "Microsoft.KeyVault.KeyNewVersionCreated"; + public const string KeyVaultSecretExpired = "Microsoft.KeyVault.SecretExpired"; + public const string KeyVaultSecretNearExpiry = "Microsoft.KeyVault.SecretNearExpiry"; + public const string KeyVaultSecretNewVersionCreated = "Microsoft.KeyVault.SecretNewVersionCreated"; + public const string MachineLearningServicesDatasetDriftDetected = "Microsoft.MachineLearningServices.DatasetDriftDetected"; + public const string MachineLearningServicesModelDeployed = "Microsoft.MachineLearningServices.ModelDeployed"; + public const string MachineLearningServicesModelRegistered = "Microsoft.MachineLearningServices.ModelRegistered"; + public const string MachineLearningServicesRunCompleted = "Microsoft.MachineLearningServices.RunCompleted"; + public const string MachineLearningServicesRunStatusChanged = "Microsoft.MachineLearningServices.RunStatusChanged"; + public const string MapsGeofenceEntered = "Microsoft.Maps.GeofenceEntered"; + public const string MapsGeofenceExited = "Microsoft.Maps.GeofenceExited"; + public const string MapsGeofenceResult = "Microsoft.Maps.GeofenceResult"; + public const string MediaJobCanceled = "Microsoft.Media.JobCanceled"; + public const string MediaJobCanceling = "Microsoft.Media.JobCanceling"; + public const string MediaJobErrored = "Microsoft.Media.JobErrored"; + public const string MediaJobFinished = "Microsoft.Media.JobFinished"; + public const string MediaJobOutputCanceled = "Microsoft.Media.JobOutputCanceled"; + public const string MediaJobOutputCanceling = "Microsoft.Media.JobOutputCanceling"; + public const string MediaJobOutputErrored = "Microsoft.Media.JobOutputErrored"; + public const string MediaJobOutputFinished = "Microsoft.Media.JobOutputFinished"; + public const string MediaJobOutputProcessing = "Microsoft.Media.JobOutputProcessing"; + public const string MediaJobOutputProgress = "Microsoft.Media.JobOutputProgress"; + public const string MediaJobOutputScheduled = "Microsoft.Media.JobOutputScheduled"; + public const string MediaJobOutputStateChange = "Microsoft.Media.JobOutputStateChange"; + public const string MediaJobProcessing = "Microsoft.Media.JobProcessing"; + public const string MediaJobScheduled = "Microsoft.Media.JobScheduled"; + public const string MediaJobStateChange = "Microsoft.Media.JobStateChange"; + public const string MediaLiveEventConnectionRejected = "Microsoft.Media.LiveEventConnectionRejected"; + public const string MediaLiveEventEncoderConnected = "Microsoft.Media.LiveEventEncoderConnected"; + public const string MediaLiveEventEncoderDisconnected = "Microsoft.Media.LiveEventEncoderDisconnected"; + public const string MediaLiveEventIncomingDataChunkDropped = "Microsoft.Media.LiveEventIncomingDataChunkDropped"; + public const string MediaLiveEventIncomingStreamReceived = "Microsoft.Media.LiveEventIncomingStreamReceived"; + public const string MediaLiveEventIncomingStreamsOutOfSync = "Microsoft.Media.LiveEventIncomingStreamsOutOfSync"; + public const string MediaLiveEventIncomingVideoStreamsOutOfSync = "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync"; + public const string MediaLiveEventIngestHeartbeat = "Microsoft.Media.LiveEventIngestHeartbeat"; + public const string MediaLiveEventTrackDiscontinuityDetected = "Microsoft.Media.LiveEventTrackDiscontinuityDetected"; + public const string ResourceActionCancel = "Microsoft.Resources.ResourceActionCancel"; + public const string ResourceActionFailure = "Microsoft.Resources.ResourceActionFailure"; + public const string ResourceActionSuccess = "Microsoft.Resources.ResourceActionSuccess"; + public const string ResourceDeleteCancel = "Microsoft.Resources.ResourceDeleteCancel"; + public const string ResourceDeleteFailure = "Microsoft.Resources.ResourceDeleteFailure"; + public const string ResourceDeleteSuccess = "Microsoft.Resources.ResourceDeleteSuccess"; + public const string ResourceWriteCancel = "Microsoft.Resources.ResourceWriteCancel"; + public const string ResourceWriteFailure = "Microsoft.Resources.ResourceWriteFailure"; + public const string ResourceWriteSuccess = "Microsoft.Resources.ResourceWriteSuccess"; + public const string ServiceBusActiveMessagesAvailableWithNoListeners = "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners"; + public const string ServiceBusDeadletterMessagesAvailableWithNoListener = "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener"; + public const string StorageBlobCreated = "Microsoft.Storage.BlobCreated"; + public const string StorageBlobDeleted = "Microsoft.Storage.BlobDeleted"; + public const string StorageBlobRenamed = "Microsoft.Storage.BlobRenamed"; + public const string StorageDirectoryCreated = "Microsoft.Storage.DirectoryCreated"; + public const string StorageDirectoryDeleted = "Microsoft.Storage.DirectoryDeleted"; + public const string StorageDirectoryRenamed = "Microsoft.Storage.DirectoryRenamed"; + public const string StorageLifecyclePolicyCompleted = "Microsoft.Storage.LifecyclePolicyCompleted"; + public const string WebAppServicePlanUpdated = "Microsoft.Web.AppServicePlanUpdated"; + public const string WebAppUpdated = "Microsoft.Web.AppUpdated"; + public const string WebBackupOperationCompleted = "Microsoft.Web.BackupOperationCompleted"; + public const string WebBackupOperationFailed = "Microsoft.Web.BackupOperationFailed"; + public const string WebBackupOperationStarted = "Microsoft.Web.BackupOperationStarted"; + public const string WebRestoreOperationCompleted = "Microsoft.Web.RestoreOperationCompleted"; + public const string WebRestoreOperationFailed = "Microsoft.Web.RestoreOperationFailed"; + public const string WebRestoreOperationStarted = "Microsoft.Web.RestoreOperationStarted"; + public const string WebSlotSwapCompleted = "Microsoft.Web.SlotSwapCompleted"; + public const string WebSlotSwapFailed = "Microsoft.Web.SlotSwapFailed"; + public const string WebSlotSwapStarted = "Microsoft.Web.SlotSwapStarted"; + public const string WebSlotSwapWithPreviewCancelled = "Microsoft.Web.SlotSwapWithPreviewCancelled"; + public const string WebSlotSwapWithPreviewStarted = "Microsoft.Web.SlotSwapWithPreviewStarted"; } } namespace Azure.Messaging.EventGrid.SystemEvents diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/samples/Sample1_PublishEventsToTopic.md b/sdk/eventgrid/Azure.Messaging.EventGrid/samples/Sample1_PublishEventsToTopic.md index ee29aa1e7d2c..a78ba7d26c96 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/samples/Sample1_PublishEventsToTopic.md +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/samples/Sample1_PublishEventsToTopic.md @@ -38,10 +38,10 @@ Note on `EventGridEvent`: each `EventGridEvent` has a set of required, non-nulla List eventsList = new List { new EventGridEvent( - "This is the event data", "ExampleEventSubject", "Example.EventType", - "1.0") + "1.0", + "This is the event data") }; // Send the events diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/samples/Sample2_PublishEventsToDomain.md b/sdk/eventgrid/Azure.Messaging.EventGrid/samples/Sample2_PublishEventsToDomain.md index 54d3f8a362c3..76a3251b75a1 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/samples/Sample2_PublishEventsToDomain.md +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/samples/Sample2_PublishEventsToDomain.md @@ -28,10 +28,10 @@ To publish events to any topic in an Event Domain, push the events to the domain List eventsList = new List { new EventGridEvent( - "This is the event data", "ExampleEventSubject", "Example.EventType", - "1.0") + "1.0", + "This is the event data") { Topic = "MyTopic" } diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/samples/Sample3_ParseAndDeserializeEvents.md b/sdk/eventgrid/Azure.Messaging.EventGrid/samples/Sample3_ParseAndDeserializeEvents.md index 1be89f566eec..3a2ebdcacd1e 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/samples/Sample3_ParseAndDeserializeEvents.md +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/samples/Sample3_ParseAndDeserializeEvents.md @@ -43,7 +43,7 @@ foreach (CloudEvent cloudEvent in cloudEvents) TestPayload testPayload = await cloudEvent.GetDataAsync(myCustomSerializer); Console.WriteLine(testPayload.Name); break; - case SystemEventMappings.StorageBlobDeletedEventName: + case SystemEventNames.StorageBlobDeleted: // Example for deserializing system events using GetData StorageBlobDeletedEventData blobDeleted = cloudEvent.GetData(); Console.WriteLine(blobDeleted.BlobType); diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Azure.Messaging.EventGrid.csproj b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Azure.Messaging.EventGrid.csproj index 4ed8183a46f6..dfb7305ed6b4 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Azure.Messaging.EventGrid.csproj +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Azure.Messaging.EventGrid.csproj @@ -29,5 +29,8 @@ + + + diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridEvent.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridEvent.cs index d07945467520..84432f6cf494 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridEvent.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridEvent.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Text; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -20,12 +19,12 @@ public class EventGridEvent { /// Initializes a new instance of . /// A resource path relative to the topic path. - /// Event data specific to the event type. /// The type of the event that occurred. For example, "Contoso.Items.ItemReceived". /// The schema version of the data object. + /// Event data specific to the event type. /// The type to use when serializing the data. /// If not specified, will be used on . - public EventGridEvent(object data, string subject, string eventType, string dataVersion, Type dataSerializationType = default) + public EventGridEvent(string subject, string eventType, string dataVersion, object data, Type dataSerializationType = default) { Argument.AssertNotNull(subject, nameof(subject)); Argument.AssertNotNull(data, nameof(data)); diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridPublisherClient.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridPublisherClient.cs index 1565b6048c72..0ab8d61206f9 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridPublisherClient.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridPublisherClient.cs @@ -50,16 +50,7 @@ public EventGridPublisherClient(Uri endpoint, AzureKeyCredential credential) { } - /// Initalizes a new instance of the class. - /// The topic endpoint. For example, "https://TOPIC-NAME.REGION-NAME-1.eventgrid.azure.net/api/events". - /// The Shared Access Signature credential used to authenticate with the service.This signature - /// can be constructed using . - public EventGridPublisherClient(Uri endpoint, AzureSasCredential credential) - : this(endpoint, credential, new EventGridPublisherClientOptions()) - { - } - - /// Initalizes a new instance of the class. + /// Initalizes a new instance of the class. /// The topic endpoint. For example, "https://TOPIC-NAME.REGION-NAME-1.eventgrid.azure.net/api/events". /// The key credential used to authenticate with the service. /// The set of options to use for configuring the client. @@ -137,9 +128,9 @@ private async Task SendCloudNativeCloudEventsInternalAsync(ReadOnlyMem /// /// The topic endpoint. For example, "https://TOPIC-NAME.REGION-NAME-1.eventgrid.azure.net/api/events". /// The Shared Access Signature credential used to connect to Azure. This signature - /// can be constructed using . + /// can be constructed using the . /// The set of options to use for configuring the client. - public EventGridPublisherClient(Uri endpoint, AzureSasCredential credential, EventGridPublisherClientOptions options) + public EventGridPublisherClient(Uri endpoint, AzureSasCredential credential, EventGridPublisherClientOptions options = default) { Argument.AssertNotNull(credential, nameof(credential)); options ??= new EventGridPublisherClientOptions(); @@ -372,38 +363,6 @@ private async Task PublishCustomEventsInternal(IEnumerable eve } } - /// - /// Creates a SAS token for use with the Event Grid service. - /// - /// The path for the event grid topic to which you're sending events. For example, "https://TOPIC-NAME.REGION-NAME.eventgrid.azure.net/eventGrid/api/events". - /// Time at which the SAS token becomes invalid for authentication. - /// The key credential used to generate the token. - /// The service version to use when handling requests made with the SAS token. - /// The generated SAS token string. - public static string BuildSharedAccessSignature(Uri endpoint, DateTimeOffset expirationUtc, AzureKeyCredential key, EventGridPublisherClientOptions.ServiceVersion apiVersion = EventGridPublisherClientOptions.LatestVersion) - { - const char Resource = 'r'; - const char Expiration = 'e'; - const char Signature = 's'; - - var uriBuilder = new RequestUriBuilder(); - uriBuilder.Reset(endpoint); - uriBuilder.AppendQuery("api-version", apiVersion.GetVersionString(), true); - string encodedResource = HttpUtility.UrlEncode(uriBuilder.ToString()); - var culture = CultureInfo.CreateSpecificCulture("en-US"); - var encodedExpirationUtc = HttpUtility.UrlEncode(expirationUtc.ToString(culture)); - - string unsignedSas = $"{Resource}={encodedResource}&{Expiration}={encodedExpirationUtc}"; - using (var hmac = new HMACSHA256(Convert.FromBase64String(key.Key))) - { - string signature = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(unsignedSas))); - string encodedSignature = HttpUtility.UrlEncode(signature); - string signedSas = $"{unsignedSas}&{Signature}={encodedSignature}"; - - return signedSas; - } - } - private JsonDocument SerializeObjectToJsonDocument(object data, Type type, CancellationToken cancellationToken) { using (MemoryStream stream = new MemoryStream()) diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridSasBuilder.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridSasBuilder.cs new file mode 100644 index 000000000000..f1a7244dd67b --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridSasBuilder.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Globalization; +using System.Security.Cryptography; +using System.Text; +using System.Web; +using Azure.Core; + +namespace Azure.Messaging.EventGrid +{ + /// + /// This is used to generate a Shared Access Signature (SAS) for an Azure Event Grid topic. + /// + public class EventGridSasBuilder + { + /// + /// Initializes a new instance of the class. + /// + /// The endpoint to generate a shared access signature for. + /// For example, "https://TOPIC-NAME.REGION-NAME.eventgrid.azure.net/eventGrid/api/events". + /// The time at which the shared access signature should expire. + public EventGridSasBuilder(Uri endpoint, DateTimeOffset expiresOn) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Endpoint = endpoint; + ExpiresOn = expiresOn; + } + + /// + /// Gets or sets the endpoint to generate a shared access signature for. + /// + public Uri Endpoint + { + get + { + return _endpoint; + } + set + { + Argument.AssertNotNull(value, nameof(value)); + _endpoint = value; + } + } + + private Uri _endpoint; + + /// + /// Gets or sets the time at which the shared access signature should expire. + /// + public DateTimeOffset ExpiresOn { get; set; } + + /// + /// Gets or sets the service version to use when generating the shared access signature. + /// + public EventGridPublisherClientOptions.ServiceVersion ApiVersion { get; set; } = EventGridPublisherClientOptions.LatestVersion; + + /// + /// Generates a shared access signature that can be used to authenticate with a topic. + /// The signature can be used as the input to the constructor. + /// This credential can then be passed to the constructor. + /// + /// The to use to authenticate with the service + /// when generating the shared access signature. + /// A shared access signature that can be used to authenticate with an Event Grid topic. + public string GenerateSas(AzureKeyCredential key) + { + Argument.AssertNotNull(key, nameof(key)); + const char Resource = 'r'; + const char Expiration = 'e'; + const char Signature = 's'; + + var uriBuilder = new RequestUriBuilder(); + uriBuilder.Reset(Endpoint); + uriBuilder.AppendQuery("api-version", ApiVersion.GetVersionString(), true); + string encodedResource = HttpUtility.UrlEncode(uriBuilder.ToString()); + var encodedExpirationUtc = HttpUtility.UrlEncode(ExpiresOn.ToString(CultureInfo.InvariantCulture)); + + string unsignedSas = $"{Resource}={encodedResource}&{Expiration}={encodedExpirationUtc}"; + using (var hmac = new HMACSHA256(Convert.FromBase64String(key.Key))) + { + string signature = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(unsignedSas))); + string encodedSignature = HttpUtility.UrlEncode(signature); + string signedSas = $"{unsignedSas}&{Signature}={encodedSignature}"; + + return signedSas; + } + } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/SystemEventExtensions.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/SystemEventExtensions.cs index 284cc159112f..384ab08f40d0 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/SystemEventExtensions.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/SystemEventExtensions.cs @@ -28,129 +28,129 @@ public static object AsSystemEventData(string eventType, JsonElement data) // Add handling for additional event types here. // AppConfiguration events - { SystemEventMappings.AppConfigurationKeyValueDeletedEventName, AppConfigurationKeyValueDeletedEventData.DeserializeAppConfigurationKeyValueDeletedEventData }, - { SystemEventMappings.AppConfigurationKeyValueModifiedEventName, AppConfigurationKeyValueModifiedEventData.DeserializeAppConfigurationKeyValueModifiedEventData }, + { SystemEventNames.AppConfigurationKeyValueDeleted, AppConfigurationKeyValueDeletedEventData.DeserializeAppConfigurationKeyValueDeletedEventData }, + { SystemEventNames.AppConfigurationKeyValueModified, AppConfigurationKeyValueModifiedEventData.DeserializeAppConfigurationKeyValueModifiedEventData }, // Communication events - { SystemEventMappings.ACSChatMemberAddedToThreadWithUserEventName, ACSChatMemberAddedToThreadWithUserEventData.DeserializeACSChatMemberAddedToThreadWithUserEventData }, - { SystemEventMappings.ACSChatMemberRemovedFromThreadWithUserEventName, ACSChatMemberRemovedFromThreadWithUserEventData.DeserializeACSChatMemberRemovedFromThreadWithUserEventData }, - { SystemEventMappings.ACSChatMessageDeletedEventName, ACSChatMessageDeletedEventData.DeserializeACSChatMessageDeletedEventData }, - { SystemEventMappings.ACSChatMessageEditedEventName, ACSChatMessageEditedEventData.DeserializeACSChatMessageEditedEventData }, - { SystemEventMappings.ACSChatMessageReceivedEventName, ACSChatMessageReceivedEventData.DeserializeACSChatMessageReceivedEventData }, - { SystemEventMappings.ACSChatThreadCreatedWithUserEventName, ACSChatThreadCreatedWithUserEventData.DeserializeACSChatThreadCreatedWithUserEventData }, - { SystemEventMappings.ACSChatThreadPropertiesUpdatedPerUserEventName, ACSChatThreadPropertiesUpdatedPerUserEventData.DeserializeACSChatThreadPropertiesUpdatedPerUserEventData }, - { SystemEventMappings.ACSChatThreadWithUserDeletedEventName, ACSChatThreadWithUserDeletedEventData.DeserializeACSChatThreadWithUserDeletedEventData }, - { SystemEventMappings.ACSSMSDeliveryReportReceivedEventName, AcsSmsDeliveryReportReceivedEventData.DeserializeAcsSmsDeliveryReportReceivedEventData }, - { SystemEventMappings.ACSSMSReceivedEventName, AcsSmsReceivedEventData.DeserializeAcsSmsReceivedEventData }, + { SystemEventNames.ACSChatMemberAddedToThreadWithUser, ACSChatMemberAddedToThreadWithUserEventData.DeserializeACSChatMemberAddedToThreadWithUserEventData }, + { SystemEventNames.ACSChatMemberRemovedFromThreadWithUser, ACSChatMemberRemovedFromThreadWithUserEventData.DeserializeACSChatMemberRemovedFromThreadWithUserEventData }, + { SystemEventNames.ACSChatMessageDeleted, ACSChatMessageDeletedEventData.DeserializeACSChatMessageDeletedEventData }, + { SystemEventNames.ACSChatMessageEdited, ACSChatMessageEditedEventData.DeserializeACSChatMessageEditedEventData }, + { SystemEventNames.ACSChatMessageReceived, ACSChatMessageReceivedEventData.DeserializeACSChatMessageReceivedEventData }, + { SystemEventNames.ACSChatThreadCreatedWithUser, ACSChatThreadCreatedWithUserEventData.DeserializeACSChatThreadCreatedWithUserEventData }, + { SystemEventNames.ACSChatThreadPropertiesUpdatedPerUser, ACSChatThreadPropertiesUpdatedPerUserEventData.DeserializeACSChatThreadPropertiesUpdatedPerUserEventData }, + { SystemEventNames.ACSChatThreadWithUserDeleted, ACSChatThreadWithUserDeletedEventData.DeserializeACSChatThreadWithUserDeletedEventData }, + { SystemEventNames.ACSSMSDeliveryReportReceived, AcsSmsDeliveryReportReceivedEventData.DeserializeAcsSmsDeliveryReportReceivedEventData }, + { SystemEventNames.ACSSMSReceived, AcsSmsReceivedEventData.DeserializeAcsSmsReceivedEventData }, // ContainerRegistry events - { SystemEventMappings.ContainerRegistryImagePushedEventName, ContainerRegistryImagePushedEventData.DeserializeContainerRegistryImagePushedEventData }, - { SystemEventMappings.ContainerRegistryImageDeletedEventName, ContainerRegistryImageDeletedEventData.DeserializeContainerRegistryImageDeletedEventData }, - { SystemEventMappings.ContainerRegistryChartDeletedEventName, ContainerRegistryChartDeletedEventData.DeserializeContainerRegistryChartDeletedEventData }, - { SystemEventMappings.ContainerRegistryChartPushedEventName, ContainerRegistryChartPushedEventData.DeserializeContainerRegistryChartPushedEventData }, + { SystemEventNames.ContainerRegistryImagePushed, ContainerRegistryImagePushedEventData.DeserializeContainerRegistryImagePushedEventData }, + { SystemEventNames.ContainerRegistryImageDeleted, ContainerRegistryImageDeletedEventData.DeserializeContainerRegistryImageDeletedEventData }, + { SystemEventNames.ContainerRegistryChartDeleted, ContainerRegistryChartDeletedEventData.DeserializeContainerRegistryChartDeletedEventData }, + { SystemEventNames.ContainerRegistryChartPushed, ContainerRegistryChartPushedEventData.DeserializeContainerRegistryChartPushedEventData }, // IoTHub Device events - { SystemEventMappings.IoTHubDeviceCreatedEventName, IotHubDeviceCreatedEventData.DeserializeIotHubDeviceCreatedEventData }, - { SystemEventMappings.IoTHubDeviceDeletedEventName, IotHubDeviceDeletedEventData.DeserializeIotHubDeviceDeletedEventData }, - { SystemEventMappings.IoTHubDeviceConnectedEventName, IotHubDeviceConnectedEventData.DeserializeIotHubDeviceConnectedEventData }, - { SystemEventMappings.IoTHubDeviceDisconnectedEventName, IotHubDeviceDisconnectedEventData.DeserializeIotHubDeviceDisconnectedEventData }, - { SystemEventMappings.IotHubDeviceTelemetryEventName, IotHubDeviceTelemetryEventData.DeserializeIotHubDeviceTelemetryEventData }, + { SystemEventNames.IoTHubDeviceCreated, IotHubDeviceCreatedEventData.DeserializeIotHubDeviceCreatedEventData }, + { SystemEventNames.IoTHubDeviceDeleted, IotHubDeviceDeletedEventData.DeserializeIotHubDeviceDeletedEventData }, + { SystemEventNames.IoTHubDeviceConnected, IotHubDeviceConnectedEventData.DeserializeIotHubDeviceConnectedEventData }, + { SystemEventNames.IoTHubDeviceDisconnected, IotHubDeviceDisconnectedEventData.DeserializeIotHubDeviceDisconnectedEventData }, + { SystemEventNames.IotHubDeviceTelemetry, IotHubDeviceTelemetryEventData.DeserializeIotHubDeviceTelemetryEventData }, // EventGrid events - { SystemEventMappings.EventGridSubscriptionValidationEventName, SubscriptionValidationEventData.DeserializeSubscriptionValidationEventData }, - { SystemEventMappings.EventGridSubscriptionDeletedEventName, SubscriptionDeletedEventData.DeserializeSubscriptionDeletedEventData }, + { SystemEventNames.EventGridSubscriptionValidation, SubscriptionValidationEventData.DeserializeSubscriptionValidationEventData }, + { SystemEventNames.EventGridSubscriptionDeleted, SubscriptionDeletedEventData.DeserializeSubscriptionDeletedEventData }, // Event Hub events - { SystemEventMappings.EventHubCaptureFileCreatedEventName, EventHubCaptureFileCreatedEventData.DeserializeEventHubCaptureFileCreatedEventData }, + { SystemEventNames.EventHubCaptureFileCreated, EventHubCaptureFileCreatedEventData.DeserializeEventHubCaptureFileCreatedEventData }, // Key Vault events - { SystemEventMappings.KeyVaultCertificateNewVersionCreatedEventName, KeyVaultCertificateNewVersionCreatedEventData.DeserializeKeyVaultCertificateNewVersionCreatedEventData }, - { SystemEventMappings.KeyVaultCertificateNearExpiryEventName, KeyVaultCertificateNearExpiryEventData.DeserializeKeyVaultCertificateNearExpiryEventData }, - { SystemEventMappings.KeyVaultCertificateExpiredEventName, KeyVaultCertificateExpiredEventData.DeserializeKeyVaultCertificateExpiredEventData }, - { SystemEventMappings.KeyVaultKeyNearExpiryEventName, KeyVaultKeyNearExpiryEventData.DeserializeKeyVaultKeyNearExpiryEventData }, - { SystemEventMappings.KeyVaultKeyNewVersionCreatedEventName, KeyVaultKeyNewVersionCreatedEventData.DeserializeKeyVaultKeyNewVersionCreatedEventData }, - { SystemEventMappings.KeyVaultKeyExpiredEventName, KeyVaultKeyExpiredEventData.DeserializeKeyVaultKeyExpiredEventData }, - { SystemEventMappings.KeyVaultSecretNewVersionCreatedEventName, KeyVaultSecretNewVersionCreatedEventData.DeserializeKeyVaultSecretNewVersionCreatedEventData }, - { SystemEventMappings.KeyVaultSecretNearExpiryEventName, KeyVaultSecretNearExpiryEventData.DeserializeKeyVaultSecretNearExpiryEventData }, - { SystemEventMappings.KeyVaultSecretExpiredEventName, KeyVaultSecretExpiredEventData.DeserializeKeyVaultSecretExpiredEventData }, - { SystemEventMappings.KeyVaultAccessPolicyChangedEventName, KeyVaultAccessPolicyChangedEventData.DeserializeKeyVaultAccessPolicyChangedEventData }, + { SystemEventNames.KeyVaultCertificateNewVersionCreated, KeyVaultCertificateNewVersionCreatedEventData.DeserializeKeyVaultCertificateNewVersionCreatedEventData }, + { SystemEventNames.KeyVaultCertificateNearExpiry, KeyVaultCertificateNearExpiryEventData.DeserializeKeyVaultCertificateNearExpiryEventData }, + { SystemEventNames.KeyVaultCertificateExpired, KeyVaultCertificateExpiredEventData.DeserializeKeyVaultCertificateExpiredEventData }, + { SystemEventNames.KeyVaultKeyNearExpiry, KeyVaultKeyNearExpiryEventData.DeserializeKeyVaultKeyNearExpiryEventData }, + { SystemEventNames.KeyVaultKeyNewVersionCreated, KeyVaultKeyNewVersionCreatedEventData.DeserializeKeyVaultKeyNewVersionCreatedEventData }, + { SystemEventNames.KeyVaultKeyExpired, KeyVaultKeyExpiredEventData.DeserializeKeyVaultKeyExpiredEventData }, + { SystemEventNames.KeyVaultSecretNewVersionCreated, KeyVaultSecretNewVersionCreatedEventData.DeserializeKeyVaultSecretNewVersionCreatedEventData }, + { SystemEventNames.KeyVaultSecretNearExpiry, KeyVaultSecretNearExpiryEventData.DeserializeKeyVaultSecretNearExpiryEventData }, + { SystemEventNames.KeyVaultSecretExpired, KeyVaultSecretExpiredEventData.DeserializeKeyVaultSecretExpiredEventData }, + { SystemEventNames.KeyVaultAccessPolicyChanged, KeyVaultAccessPolicyChangedEventData.DeserializeKeyVaultAccessPolicyChangedEventData }, // MachineLearningServices events - { SystemEventMappings.MachineLearningServicesDatasetDriftDetectedEventName, MachineLearningServicesDatasetDriftDetectedEventData.DeserializeMachineLearningServicesDatasetDriftDetectedEventData }, - { SystemEventMappings.MachineLearningServicesModelDeployedEventName, MachineLearningServicesModelDeployedEventData.DeserializeMachineLearningServicesModelDeployedEventData }, - { SystemEventMappings.MachineLearningServicesModelRegisteredEventName, MachineLearningServicesModelRegisteredEventData.DeserializeMachineLearningServicesModelRegisteredEventData }, - { SystemEventMappings.MachineLearningServicesRunCompletedEventName, MachineLearningServicesRunCompletedEventData.DeserializeMachineLearningServicesRunCompletedEventData }, - { SystemEventMappings.MachineLearningServicesRunStatusChangedEventName, MachineLearningServicesRunStatusChangedEventData.DeserializeMachineLearningServicesRunStatusChangedEventData }, + { SystemEventNames.MachineLearningServicesDatasetDriftDetected, MachineLearningServicesDatasetDriftDetectedEventData.DeserializeMachineLearningServicesDatasetDriftDetectedEventData }, + { SystemEventNames.MachineLearningServicesModelDeployed, MachineLearningServicesModelDeployedEventData.DeserializeMachineLearningServicesModelDeployedEventData }, + { SystemEventNames.MachineLearningServicesModelRegistered, MachineLearningServicesModelRegisteredEventData.DeserializeMachineLearningServicesModelRegisteredEventData }, + { SystemEventNames.MachineLearningServicesRunCompleted, MachineLearningServicesRunCompletedEventData.DeserializeMachineLearningServicesRunCompletedEventData }, + { SystemEventNames.MachineLearningServicesRunStatusChanged, MachineLearningServicesRunStatusChangedEventData.DeserializeMachineLearningServicesRunStatusChangedEventData }, // Maps events - { SystemEventMappings.MapsGeofenceEnteredEventName, MapsGeofenceEnteredEventData.DeserializeMapsGeofenceEnteredEventData }, - { SystemEventMappings.MapsGeofenceExitedEventName, MapsGeofenceExitedEventData.DeserializeMapsGeofenceExitedEventData }, - { SystemEventMappings.MapsGeofenceResultEventName, MapsGeofenceResultEventData.DeserializeMapsGeofenceResultEventData }, + { SystemEventNames.MapsGeofenceEntered, MapsGeofenceEnteredEventData.DeserializeMapsGeofenceEnteredEventData }, + { SystemEventNames.MapsGeofenceExited, MapsGeofenceExitedEventData.DeserializeMapsGeofenceExitedEventData }, + { SystemEventNames.MapsGeofenceResult, MapsGeofenceResultEventData.DeserializeMapsGeofenceResultEventData }, // Media Services events - { SystemEventMappings.MediaJobStateChangeEventName, MediaJobStateChangeEventData.DeserializeMediaJobStateChangeEventData }, - { SystemEventMappings.MediaJobOutputStateChangeEventName, MediaJobOutputStateChangeEventData.DeserializeMediaJobOutputStateChangeEventData }, - { SystemEventMappings.MediaJobScheduledEventName, MediaJobScheduledEventData.DeserializeMediaJobScheduledEventData }, - { SystemEventMappings.MediaJobProcessingEventName, MediaJobProcessingEventData.DeserializeMediaJobProcessingEventData }, - { SystemEventMappings.MediaJobCancelingEventName, MediaJobCancelingEventData.DeserializeMediaJobCancelingEventData }, - { SystemEventMappings.MediaJobFinishedEventName, MediaJobFinishedEventData.DeserializeMediaJobFinishedEventData }, - { SystemEventMappings.MediaJobCanceledEventName, MediaJobCanceledEventData.DeserializeMediaJobCanceledEventData }, - { SystemEventMappings.MediaJobErroredEventName, MediaJobErroredEventData.DeserializeMediaJobErroredEventData }, - { SystemEventMappings.MediaJobOutputCanceledEventName, MediaJobOutputCanceledEventData.DeserializeMediaJobOutputCanceledEventData }, - { SystemEventMappings.MediaJobOutputCancelingEventName, MediaJobOutputCancelingEventData.DeserializeMediaJobOutputCancelingEventData }, - { SystemEventMappings.MediaJobOutputErroredEventName, MediaJobOutputErroredEventData.DeserializeMediaJobOutputErroredEventData }, - { SystemEventMappings.MediaJobOutputFinishedEventName, MediaJobOutputFinishedEventData.DeserializeMediaJobOutputFinishedEventData }, - { SystemEventMappings.MediaJobOutputProcessingEventName, MediaJobOutputProcessingEventData.DeserializeMediaJobOutputProcessingEventData }, - { SystemEventMappings.MediaJobOutputScheduledEventName, MediaJobOutputScheduledEventData.DeserializeMediaJobOutputScheduledEventData }, - { SystemEventMappings.MediaJobOutputProgressEventName, MediaJobOutputProgressEventData.DeserializeMediaJobOutputProgressEventData }, - { SystemEventMappings.MediaLiveEventEncoderConnectedEventName, MediaLiveEventEncoderConnectedEventData.DeserializeMediaLiveEventEncoderConnectedEventData }, - { SystemEventMappings.MediaLiveEventConnectionRejectedEventName, MediaLiveEventConnectionRejectedEventData.DeserializeMediaLiveEventConnectionRejectedEventData }, - { SystemEventMappings.MediaLiveEventEncoderDisconnectedEventName, MediaLiveEventEncoderDisconnectedEventData.DeserializeMediaLiveEventEncoderDisconnectedEventData }, - { SystemEventMappings.MediaLiveEventIncomingStreamReceivedEventName, MediaLiveEventIncomingStreamReceivedEventData.DeserializeMediaLiveEventIncomingStreamReceivedEventData }, - { SystemEventMappings.MediaLiveEventIncomingStreamsOutOfSyncEventName, MediaLiveEventIncomingStreamsOutOfSyncEventData.DeserializeMediaLiveEventIncomingStreamsOutOfSyncEventData }, - { SystemEventMappings.MediaLiveEventIncomingVideoStreamsOutOfSyncEventName, MediaLiveEventIncomingVideoStreamsOutOfSyncEventData.DeserializeMediaLiveEventIncomingVideoStreamsOutOfSyncEventData }, - { SystemEventMappings.MediaLiveEventIncomingDataChunkDroppedEventName, MediaLiveEventIncomingDataChunkDroppedEventData.DeserializeMediaLiveEventIncomingDataChunkDroppedEventData }, - { SystemEventMappings.MediaLiveEventIngestHeartbeatEventName, MediaLiveEventIngestHeartbeatEventData.DeserializeMediaLiveEventIngestHeartbeatEventData }, - { SystemEventMappings.MediaLiveEventTrackDiscontinuityDetectedEventName, MediaLiveEventTrackDiscontinuityDetectedEventData.DeserializeMediaLiveEventTrackDiscontinuityDetectedEventData }, + { SystemEventNames.MediaJobStateChange, MediaJobStateChangeEventData.DeserializeMediaJobStateChangeEventData }, + { SystemEventNames.MediaJobOutputStateChange, MediaJobOutputStateChangeEventData.DeserializeMediaJobOutputStateChangeEventData }, + { SystemEventNames.MediaJobScheduled, MediaJobScheduledEventData.DeserializeMediaJobScheduledEventData }, + { SystemEventNames.MediaJobProcessing, MediaJobProcessingEventData.DeserializeMediaJobProcessingEventData }, + { SystemEventNames.MediaJobCanceling, MediaJobCancelingEventData.DeserializeMediaJobCancelingEventData }, + { SystemEventNames.MediaJobFinished, MediaJobFinishedEventData.DeserializeMediaJobFinishedEventData }, + { SystemEventNames.MediaJobCanceled, MediaJobCanceledEventData.DeserializeMediaJobCanceledEventData }, + { SystemEventNames.MediaJobErrored, MediaJobErroredEventData.DeserializeMediaJobErroredEventData }, + { SystemEventNames.MediaJobOutputCanceled, MediaJobOutputCanceledEventData.DeserializeMediaJobOutputCanceledEventData }, + { SystemEventNames.MediaJobOutputCanceling, MediaJobOutputCancelingEventData.DeserializeMediaJobOutputCancelingEventData }, + { SystemEventNames.MediaJobOutputErrored, MediaJobOutputErroredEventData.DeserializeMediaJobOutputErroredEventData }, + { SystemEventNames.MediaJobOutputFinished, MediaJobOutputFinishedEventData.DeserializeMediaJobOutputFinishedEventData }, + { SystemEventNames.MediaJobOutputProcessing, MediaJobOutputProcessingEventData.DeserializeMediaJobOutputProcessingEventData }, + { SystemEventNames.MediaJobOutputScheduled, MediaJobOutputScheduledEventData.DeserializeMediaJobOutputScheduledEventData }, + { SystemEventNames.MediaJobOutputProgress, MediaJobOutputProgressEventData.DeserializeMediaJobOutputProgressEventData }, + { SystemEventNames.MediaLiveEventEncoderConnected, MediaLiveEventEncoderConnectedEventData.DeserializeMediaLiveEventEncoderConnectedEventData }, + { SystemEventNames.MediaLiveEventConnectionRejected, MediaLiveEventConnectionRejectedEventData.DeserializeMediaLiveEventConnectionRejectedEventData }, + { SystemEventNames.MediaLiveEventEncoderDisconnected, MediaLiveEventEncoderDisconnectedEventData.DeserializeMediaLiveEventEncoderDisconnectedEventData }, + { SystemEventNames.MediaLiveEventIncomingStreamReceived, MediaLiveEventIncomingStreamReceivedEventData.DeserializeMediaLiveEventIncomingStreamReceivedEventData }, + { SystemEventNames.MediaLiveEventIncomingStreamsOutOfSync, MediaLiveEventIncomingStreamsOutOfSyncEventData.DeserializeMediaLiveEventIncomingStreamsOutOfSyncEventData }, + { SystemEventNames.MediaLiveEventIncomingVideoStreamsOutOfSync, MediaLiveEventIncomingVideoStreamsOutOfSyncEventData.DeserializeMediaLiveEventIncomingVideoStreamsOutOfSyncEventData }, + { SystemEventNames.MediaLiveEventIncomingDataChunkDropped, MediaLiveEventIncomingDataChunkDroppedEventData.DeserializeMediaLiveEventIncomingDataChunkDroppedEventData }, + { SystemEventNames.MediaLiveEventIngestHeartbeat, MediaLiveEventIngestHeartbeatEventData.DeserializeMediaLiveEventIngestHeartbeatEventData }, + { SystemEventNames.MediaLiveEventTrackDiscontinuityDetected, MediaLiveEventTrackDiscontinuityDetectedEventData.DeserializeMediaLiveEventTrackDiscontinuityDetectedEventData }, // Resource Manager (Azure Subscription/Resource Group) events - { SystemEventMappings.ResourceWriteSuccessEventName, ResourceWriteSuccessData.DeserializeResourceWriteSuccessData }, - { SystemEventMappings.ResourceWriteFailureEventName, ResourceWriteFailureData.DeserializeResourceWriteFailureData }, - { SystemEventMappings.ResourceWriteCancelEventName, ResourceWriteCancelData.DeserializeResourceWriteCancelData }, - { SystemEventMappings.ResourceDeleteSuccessEventName, ResourceDeleteSuccessData.DeserializeResourceDeleteSuccessData }, - { SystemEventMappings.ResourceDeleteFailureEventName, ResourceDeleteFailureData.DeserializeResourceDeleteFailureData }, - { SystemEventMappings.ResourceDeleteCancelEventName, ResourceDeleteCancelData.DeserializeResourceDeleteCancelData }, - { SystemEventMappings.ResourceActionSuccessEventName, ResourceActionSuccessData.DeserializeResourceActionSuccessData }, - { SystemEventMappings.ResourceActionFailureEventName, ResourceActionFailureData.DeserializeResourceActionFailureData }, - { SystemEventMappings.ResourceActionCancelEventName, ResourceActionCancelData.DeserializeResourceActionCancelData }, + { SystemEventNames.ResourceWriteSuccess, ResourceWriteSuccessData.DeserializeResourceWriteSuccessData }, + { SystemEventNames.ResourceWriteFailure, ResourceWriteFailureData.DeserializeResourceWriteFailureData }, + { SystemEventNames.ResourceWriteCancel, ResourceWriteCancelData.DeserializeResourceWriteCancelData }, + { SystemEventNames.ResourceDeleteSuccess, ResourceDeleteSuccessData.DeserializeResourceDeleteSuccessData }, + { SystemEventNames.ResourceDeleteFailure, ResourceDeleteFailureData.DeserializeResourceDeleteFailureData }, + { SystemEventNames.ResourceDeleteCancel, ResourceDeleteCancelData.DeserializeResourceDeleteCancelData }, + { SystemEventNames.ResourceActionSuccess, ResourceActionSuccessData.DeserializeResourceActionSuccessData }, + { SystemEventNames.ResourceActionFailure, ResourceActionFailureData.DeserializeResourceActionFailureData }, + { SystemEventNames.ResourceActionCancel, ResourceActionCancelData.DeserializeResourceActionCancelData }, // ServiceBus events - { SystemEventMappings.ServiceBusActiveMessagesAvailableWithNoListenersEventName, ServiceBusActiveMessagesAvailableWithNoListenersEventData.DeserializeServiceBusActiveMessagesAvailableWithNoListenersEventData }, - { SystemEventMappings.ServiceBusDeadletterMessagesAvailableWithNoListenerEventName, ServiceBusDeadletterMessagesAvailableWithNoListenersEventData.DeserializeServiceBusDeadletterMessagesAvailableWithNoListenersEventData }, + { SystemEventNames.ServiceBusActiveMessagesAvailableWithNoListeners, ServiceBusActiveMessagesAvailableWithNoListenersEventData.DeserializeServiceBusActiveMessagesAvailableWithNoListenersEventData }, + { SystemEventNames.ServiceBusDeadletterMessagesAvailableWithNoListener, ServiceBusDeadletterMessagesAvailableWithNoListenersEventData.DeserializeServiceBusDeadletterMessagesAvailableWithNoListenersEventData }, // Storage events - { SystemEventMappings.StorageBlobCreatedEventName, StorageBlobCreatedEventData.DeserializeStorageBlobCreatedEventData }, - { SystemEventMappings.StorageBlobDeletedEventName, StorageBlobDeletedEventData.DeserializeStorageBlobDeletedEventData }, - { SystemEventMappings.StorageBlobRenamedEventName, StorageBlobRenamedEventData.DeserializeStorageBlobRenamedEventData }, - { SystemEventMappings.StorageDirectoryCreatedEventName, StorageDirectoryCreatedEventData.DeserializeStorageDirectoryCreatedEventData }, - { SystemEventMappings.StorageDirectoryDeletedEventName, StorageDirectoryDeletedEventData.DeserializeStorageDirectoryDeletedEventData }, - { SystemEventMappings.StorageDirectoryRenamedEventName, StorageDirectoryRenamedEventData.DeserializeStorageDirectoryRenamedEventData }, - { SystemEventMappings.StorageLifecyclePolicyCompletedEventName, StorageLifecyclePolicyCompletedEventData.DeserializeStorageLifecyclePolicyCompletedEventData }, + { SystemEventNames.StorageBlobCreated, StorageBlobCreatedEventData.DeserializeStorageBlobCreatedEventData }, + { SystemEventNames.StorageBlobDeleted, StorageBlobDeletedEventData.DeserializeStorageBlobDeletedEventData }, + { SystemEventNames.StorageBlobRenamed, StorageBlobRenamedEventData.DeserializeStorageBlobRenamedEventData }, + { SystemEventNames.StorageDirectoryCreated, StorageDirectoryCreatedEventData.DeserializeStorageDirectoryCreatedEventData }, + { SystemEventNames.StorageDirectoryDeleted, StorageDirectoryDeletedEventData.DeserializeStorageDirectoryDeletedEventData }, + { SystemEventNames.StorageDirectoryRenamed, StorageDirectoryRenamedEventData.DeserializeStorageDirectoryRenamedEventData }, + { SystemEventNames.StorageLifecyclePolicyCompleted, StorageLifecyclePolicyCompletedEventData.DeserializeStorageLifecyclePolicyCompletedEventData }, // App Service - { SystemEventMappings.WebAppUpdatedEventName, WebAppUpdatedEventData.DeserializeWebAppUpdatedEventData }, - { SystemEventMappings.WebBackupOperationStartedEventName, WebBackupOperationStartedEventData.DeserializeWebBackupOperationStartedEventData }, - { SystemEventMappings.WebBackupOperationCompletedEventName, WebBackupOperationCompletedEventData.DeserializeWebBackupOperationCompletedEventData }, - { SystemEventMappings.WebBackupOperationFailedEventName, WebBackupOperationFailedEventData.DeserializeWebBackupOperationFailedEventData }, - { SystemEventMappings.WebRestoreOperationStartedEventName, WebRestoreOperationStartedEventData.DeserializeWebRestoreOperationStartedEventData }, - { SystemEventMappings.WebRestoreOperationCompletedEventName, WebRestoreOperationCompletedEventData.DeserializeWebRestoreOperationCompletedEventData }, - { SystemEventMappings.WebRestoreOperationFailedEventName, WebRestoreOperationFailedEventData.DeserializeWebRestoreOperationFailedEventData }, - { SystemEventMappings.WebSlotSwapStartedEventName, WebSlotSwapStartedEventData.DeserializeWebSlotSwapStartedEventData }, - { SystemEventMappings.WebSlotSwapCompletedEventName, WebSlotSwapCompletedEventData.DeserializeWebSlotSwapCompletedEventData }, - { SystemEventMappings.WebSlotSwapFailedEventName, WebSlotSwapFailedEventData.DeserializeWebSlotSwapFailedEventData }, - { SystemEventMappings.WebSlotSwapWithPreviewStartedEventName, WebSlotSwapWithPreviewStartedEventData.DeserializeWebSlotSwapWithPreviewStartedEventData }, - { SystemEventMappings.WebSlotSwapWithPreviewCancelledEventName, WebSlotSwapWithPreviewCancelledEventData.DeserializeWebSlotSwapWithPreviewCancelledEventData }, - { SystemEventMappings.WebAppServicePlanUpdatedEventName, WebAppServicePlanUpdatedEventData.DeserializeWebAppServicePlanUpdatedEventData } + { SystemEventNames.WebAppUpdated, WebAppUpdatedEventData.DeserializeWebAppUpdatedEventData }, + { SystemEventNames.WebBackupOperationStarted, WebBackupOperationStartedEventData.DeserializeWebBackupOperationStartedEventData }, + { SystemEventNames.WebBackupOperationCompleted, WebBackupOperationCompletedEventData.DeserializeWebBackupOperationCompletedEventData }, + { SystemEventNames.WebBackupOperationFailed, WebBackupOperationFailedEventData.DeserializeWebBackupOperationFailedEventData }, + { SystemEventNames.WebRestoreOperationStarted, WebRestoreOperationStartedEventData.DeserializeWebRestoreOperationStartedEventData }, + { SystemEventNames.WebRestoreOperationCompleted, WebRestoreOperationCompletedEventData.DeserializeWebRestoreOperationCompletedEventData }, + { SystemEventNames.WebRestoreOperationFailed, WebRestoreOperationFailedEventData.DeserializeWebRestoreOperationFailedEventData }, + { SystemEventNames.WebSlotSwapStarted, WebSlotSwapStartedEventData.DeserializeWebSlotSwapStartedEventData }, + { SystemEventNames.WebSlotSwapCompleted, WebSlotSwapCompletedEventData.DeserializeWebSlotSwapCompletedEventData }, + { SystemEventNames.WebSlotSwapFailed, WebSlotSwapFailedEventData.DeserializeWebSlotSwapFailedEventData }, + { SystemEventNames.WebSlotSwapWithPreviewStarted, WebSlotSwapWithPreviewStartedEventData.DeserializeWebSlotSwapWithPreviewStartedEventData }, + { SystemEventNames.WebSlotSwapWithPreviewCancelled, WebSlotSwapWithPreviewCancelledEventData.DeserializeWebSlotSwapWithPreviewCancelledEventData }, + { SystemEventNames.WebAppServicePlanUpdated, WebAppServicePlanUpdatedEventData.DeserializeWebAppServicePlanUpdatedEventData } }; } } diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/SystemEventMappings.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/SystemEventNames.cs similarity index 73% rename from sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/SystemEventMappings.cs rename to sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/SystemEventNames.cs index dda04a3c6ee9..b36b51806a0a 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/SystemEventMappings.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/SystemEventNames.cs @@ -9,7 +9,7 @@ namespace Azure.Messaging.EventGrid /// Represents the names of the various event types for the system events published to /// Azure Event Grid. /// - public static class SystemEventMappings + public static class SystemEventNames { // Keep this sorted by the name of the service publishing the events. @@ -18,13 +18,13 @@ public static class SystemEventMappings /// The value of the Event Type stored in and for the /// system event. /// - public const string AppConfigurationKeyValueDeletedEventName = "Microsoft.AppConfiguration.KeyValueDeleted"; + public const string AppConfigurationKeyValueDeleted = "Microsoft.AppConfiguration.KeyValueDeleted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string AppConfigurationKeyValueModifiedEventName = "Microsoft.AppConfiguration.KeyValueModified"; + public const string AppConfigurationKeyValueModified = "Microsoft.AppConfiguration.KeyValueModified"; #endregion #region Communication events @@ -32,61 +32,61 @@ public static class SystemEventMappings /// The value of the Event Type stored in and for the /// system event. /// - public const string ACSChatMemberAddedToThreadWithUserEventName = "Microsoft.Communication.ChatMemberAddedToThreadWithUser"; + public const string ACSChatMemberAddedToThreadWithUser = "Microsoft.Communication.ChatMemberAddedToThreadWithUser"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ACSChatMemberRemovedFromThreadWithUserEventName = "Microsoft.Communication.ChatMemberRemovedFromThreadWithUser"; + public const string ACSChatMemberRemovedFromThreadWithUser = "Microsoft.Communication.ChatMemberRemovedFromThreadWithUser"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ACSChatMessageDeletedEventName = "Microsoft.Communication.ChatMessageDeleted"; + public const string ACSChatMessageDeleted = "Microsoft.Communication.ChatMessageDeleted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ACSChatMessageEditedEventName = "Microsoft.Communication.ChatMessageEdited"; + public const string ACSChatMessageEdited = "Microsoft.Communication.ChatMessageEdited"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ACSChatMessageReceivedEventName = "Microsoft.Communication.ChatMessageReceived"; + public const string ACSChatMessageReceived = "Microsoft.Communication.ChatMessageReceived"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ACSChatThreadCreatedWithUserEventName = "Microsoft.Communication.ChatThreadCreatedWithUser"; + public const string ACSChatThreadCreatedWithUser = "Microsoft.Communication.ChatThreadCreatedWithUser"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ACSChatThreadPropertiesUpdatedPerUserEventName = "Microsoft.Communication.ChatThreadPropertiesUpdatedPerUser"; + public const string ACSChatThreadPropertiesUpdatedPerUser = "Microsoft.Communication.ChatThreadPropertiesUpdatedPerUser"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ACSChatThreadWithUserDeletedEventName = "Microsoft.Communication.ChatThreadWithUserDeleted"; + public const string ACSChatThreadWithUserDeleted = "Microsoft.Communication.ChatThreadWithUserDeleted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ACSSMSDeliveryReportReceivedEventName = "Microsoft.Communication.SMSDeliveryReportReceived"; + public const string ACSSMSDeliveryReportReceived = "Microsoft.Communication.SMSDeliveryReportReceived"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ACSSMSReceivedEventName = "Microsoft.Communication.SMSReceived"; + public const string ACSSMSReceived = "Microsoft.Communication.SMSReceived"; #endregion #region ContainerRegistry events @@ -94,25 +94,25 @@ public static class SystemEventMappings /// The value of the Event Type stored in and for the /// system event. /// - public const string ContainerRegistryImagePushedEventName = "Microsoft.ContainerRegistry.ImagePushed"; + public const string ContainerRegistryImagePushed = "Microsoft.ContainerRegistry.ImagePushed"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ContainerRegistryImageDeletedEventName = "Microsoft.ContainerRegistry.ImageDeleted"; + public const string ContainerRegistryImageDeleted = "Microsoft.ContainerRegistry.ImageDeleted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ContainerRegistryChartDeletedEventName = "Microsoft.ContainerRegistry.ChartDeleted"; + public const string ContainerRegistryChartDeleted = "Microsoft.ContainerRegistry.ChartDeleted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ContainerRegistryChartPushedEventName = "Microsoft.ContainerRegistry.ChartPushed"; + public const string ContainerRegistryChartPushed = "Microsoft.ContainerRegistry.ChartPushed"; #endregion #region Device events @@ -120,31 +120,31 @@ public static class SystemEventMappings /// The value of the Event Type stored in and for the /// system event. /// - public const string IoTHubDeviceCreatedEventName = "Microsoft.Devices.DeviceCreated"; + public const string IoTHubDeviceCreated = "Microsoft.Devices.DeviceCreated"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string IoTHubDeviceDeletedEventName = "Microsoft.Devices.DeviceDeleted"; + public const string IoTHubDeviceDeleted = "Microsoft.Devices.DeviceDeleted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string IoTHubDeviceConnectedEventName = "Microsoft.Devices.DeviceConnected"; + public const string IoTHubDeviceConnected = "Microsoft.Devices.DeviceConnected"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string IoTHubDeviceDisconnectedEventName = "Microsoft.Devices.DeviceDisconnected"; + public const string IoTHubDeviceDisconnected = "Microsoft.Devices.DeviceDisconnected"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string IotHubDeviceTelemetryEventName = "Microsoft.Devices.DeviceTelemetry"; + public const string IotHubDeviceTelemetry = "Microsoft.Devices.DeviceTelemetry"; #endregion #region EventGrid events @@ -152,20 +152,20 @@ public static class SystemEventMappings /// The value of the Event Type stored in and for the /// system event. /// - public const string EventGridSubscriptionValidationEventName = "Microsoft.EventGrid.SubscriptionValidationEvent"; + public const string EventGridSubscriptionValidation = "Microsoft.EventGrid.SubscriptionValidationEvent"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string EventGridSubscriptionDeletedEventName = "Microsoft.EventGrid.SubscriptionDeletedEvent"; + public const string EventGridSubscriptionDeleted = "Microsoft.EventGrid.SubscriptionDeletedEvent"; // Event Hub Events /// /// The value of the Event Type stored in and for the /// system event. /// - public const string EventHubCaptureFileCreatedEventName = "Microsoft.EventHub.CaptureFileCreated"; + public const string EventHubCaptureFileCreated = "Microsoft.EventHub.CaptureFileCreated"; #endregion #region Key Vault Events @@ -173,61 +173,61 @@ public static class SystemEventMappings /// The value of the Event Type stored in and for the /// system event. /// - public const string KeyVaultCertificateNewVersionCreatedEventName = "Microsoft.KeyVault.CertificateNewVersionCreated"; + public const string KeyVaultCertificateNewVersionCreated = "Microsoft.KeyVault.CertificateNewVersionCreated"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string KeyVaultCertificateNearExpiryEventName = "Microsoft.KeyVault.CertificateNearExpiry"; + public const string KeyVaultCertificateNearExpiry = "Microsoft.KeyVault.CertificateNearExpiry"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string KeyVaultCertificateExpiredEventName = "Microsoft.KeyVault.CertificateExpired"; + public const string KeyVaultCertificateExpired = "Microsoft.KeyVault.CertificateExpired"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string KeyVaultKeyNewVersionCreatedEventName = "Microsoft.KeyVault.KeyNewVersionCreated"; + public const string KeyVaultKeyNewVersionCreated = "Microsoft.KeyVault.KeyNewVersionCreated"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string KeyVaultKeyNearExpiryEventName = "Microsoft.KeyVault.KeyNearExpiry"; + public const string KeyVaultKeyNearExpiry = "Microsoft.KeyVault.KeyNearExpiry"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string KeyVaultKeyExpiredEventName = "Microsoft.KeyVault.KeyExpired"; + public const string KeyVaultKeyExpired = "Microsoft.KeyVault.KeyExpired"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string KeyVaultSecretNewVersionCreatedEventName = "Microsoft.KeyVault.SecretNewVersionCreated"; + public const string KeyVaultSecretNewVersionCreated = "Microsoft.KeyVault.SecretNewVersionCreated"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string KeyVaultSecretNearExpiryEventName = "Microsoft.KeyVault.SecretNearExpiry"; + public const string KeyVaultSecretNearExpiry = "Microsoft.KeyVault.SecretNearExpiry"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string KeyVaultSecretExpiredEventName = "Microsoft.KeyVault.SecretExpired"; + public const string KeyVaultSecretExpired = "Microsoft.KeyVault.SecretExpired"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string KeyVaultAccessPolicyChangedEventName = "Microsoft.KeyVault.VaultAccessPolicyChanged"; + public const string KeyVaultAccessPolicyChanged = "Microsoft.KeyVault.VaultAccessPolicyChanged"; #endregion #region MachineLearningServices events @@ -235,31 +235,31 @@ public static class SystemEventMappings /// The value of the Event Type stored in and for the /// system event. /// - public const string MachineLearningServicesDatasetDriftDetectedEventName = "Microsoft.MachineLearningServices.DatasetDriftDetected"; + public const string MachineLearningServicesDatasetDriftDetected = "Microsoft.MachineLearningServices.DatasetDriftDetected"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MachineLearningServicesModelDeployedEventName = "Microsoft.MachineLearningServices.ModelDeployed"; + public const string MachineLearningServicesModelDeployed = "Microsoft.MachineLearningServices.ModelDeployed"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MachineLearningServicesModelRegisteredEventName = "Microsoft.MachineLearningServices.ModelRegistered"; + public const string MachineLearningServicesModelRegistered = "Microsoft.MachineLearningServices.ModelRegistered"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MachineLearningServicesRunCompletedEventName = "Microsoft.MachineLearningServices.RunCompleted"; + public const string MachineLearningServicesRunCompleted = "Microsoft.MachineLearningServices.RunCompleted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MachineLearningServicesRunStatusChangedEventName = "Microsoft.MachineLearningServices.RunStatusChanged"; + public const string MachineLearningServicesRunStatusChanged = "Microsoft.MachineLearningServices.RunStatusChanged"; #endregion #region Maps events @@ -267,19 +267,19 @@ public static class SystemEventMappings /// The value of the Event Type stored in and for the /// system event. /// - public const string MapsGeofenceEnteredEventName = "Microsoft.Maps.GeofenceEntered"; + public const string MapsGeofenceEntered = "Microsoft.Maps.GeofenceEntered"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MapsGeofenceExitedEventName = "Microsoft.Maps.GeofenceExited"; + public const string MapsGeofenceExited = "Microsoft.Maps.GeofenceExited"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MapsGeofenceResultEventName = "Microsoft.Maps.GeofenceResult"; + public const string MapsGeofenceResult = "Microsoft.Maps.GeofenceResult"; #endregion #region Media Services events @@ -288,145 +288,145 @@ public static class SystemEventMappings /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaJobStateChangeEventName= "Microsoft.Media.JobStateChange"; + public const string MediaJobStateChange= "Microsoft.Media.JobStateChange"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaJobOutputStateChangeEventName = "Microsoft.Media.JobOutputStateChange"; + public const string MediaJobOutputStateChange = "Microsoft.Media.JobOutputStateChange"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaJobScheduledEventName = "Microsoft.Media.JobScheduled"; + public const string MediaJobScheduled = "Microsoft.Media.JobScheduled"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaJobProcessingEventName = "Microsoft.Media.JobProcessing"; + public const string MediaJobProcessing = "Microsoft.Media.JobProcessing"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaJobCancelingEventName = "Microsoft.Media.JobCanceling"; + public const string MediaJobCanceling = "Microsoft.Media.JobCanceling"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaJobFinishedEventName = "Microsoft.Media.JobFinished"; + public const string MediaJobFinished = "Microsoft.Media.JobFinished"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaJobCanceledEventName = "Microsoft.Media.JobCanceled"; + public const string MediaJobCanceled = "Microsoft.Media.JobCanceled"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaJobErroredEventName = "Microsoft.Media.JobErrored"; + public const string MediaJobErrored = "Microsoft.Media.JobErrored"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaJobOutputCanceledEventName = "Microsoft.Media.JobOutputCanceled"; + public const string MediaJobOutputCanceled = "Microsoft.Media.JobOutputCanceled"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaJobOutputCancelingEventName = "Microsoft.Media.JobOutputCanceling"; + public const string MediaJobOutputCanceling = "Microsoft.Media.JobOutputCanceling"; /// /// The value of the Event Type stored in and for the /// MediaJobOutputErroredEvent system event. /// - public const string MediaJobOutputErroredEventName = "Microsoft.Media.JobOutputErrored"; + public const string MediaJobOutputErrored = "Microsoft.Media.JobOutputErrored"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaJobOutputFinishedEventName = "Microsoft.Media.JobOutputFinished"; + public const string MediaJobOutputFinished = "Microsoft.Media.JobOutputFinished"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaJobOutputProcessingEventName = "Microsoft.Media.JobOutputProcessing"; + public const string MediaJobOutputProcessing = "Microsoft.Media.JobOutputProcessing"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaJobOutputScheduledEventName = "Microsoft.Media.JobOutputScheduled"; + public const string MediaJobOutputScheduled = "Microsoft.Media.JobOutputScheduled"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaJobOutputProgressEventName = "Microsoft.Media.JobOutputProgress"; + public const string MediaJobOutputProgress = "Microsoft.Media.JobOutputProgress"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaLiveEventEncoderConnectedEventName = "Microsoft.Media.LiveEventEncoderConnected"; + public const string MediaLiveEventEncoderConnected = "Microsoft.Media.LiveEventEncoderConnected"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaLiveEventConnectionRejectedEventName = "Microsoft.Media.LiveEventConnectionRejected"; + public const string MediaLiveEventConnectionRejected = "Microsoft.Media.LiveEventConnectionRejected"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaLiveEventEncoderDisconnectedEventName = "Microsoft.Media.LiveEventEncoderDisconnected"; + public const string MediaLiveEventEncoderDisconnected = "Microsoft.Media.LiveEventEncoderDisconnected"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaLiveEventIncomingStreamReceivedEventName = "Microsoft.Media.LiveEventIncomingStreamReceived"; + public const string MediaLiveEventIncomingStreamReceived = "Microsoft.Media.LiveEventIncomingStreamReceived"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaLiveEventIncomingStreamsOutOfSyncEventName = "Microsoft.Media.LiveEventIncomingStreamsOutOfSync"; + public const string MediaLiveEventIncomingStreamsOutOfSync = "Microsoft.Media.LiveEventIncomingStreamsOutOfSync"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaLiveEventIncomingVideoStreamsOutOfSyncEventName = "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync"; + public const string MediaLiveEventIncomingVideoStreamsOutOfSync = "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaLiveEventIncomingDataChunkDroppedEventName = "Microsoft.Media.LiveEventIncomingDataChunkDropped"; + public const string MediaLiveEventIncomingDataChunkDropped = "Microsoft.Media.LiveEventIncomingDataChunkDropped"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaLiveEventIngestHeartbeatEventName = "Microsoft.Media.LiveEventIngestHeartbeat"; + public const string MediaLiveEventIngestHeartbeat = "Microsoft.Media.LiveEventIngestHeartbeat"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string MediaLiveEventTrackDiscontinuityDetectedEventName = "Microsoft.Media.LiveEventTrackDiscontinuityDetected"; + public const string MediaLiveEventTrackDiscontinuityDetected = "Microsoft.Media.LiveEventTrackDiscontinuityDetected"; #endregion #region Resource Manager (Azure Subscription/Resource Group) events @@ -434,55 +434,55 @@ public static class SystemEventMappings /// The value of the Event Type stored in and for the /// system event. /// - public const string ResourceWriteSuccessEventName = "Microsoft.Resources.ResourceWriteSuccess"; + public const string ResourceWriteSuccess = "Microsoft.Resources.ResourceWriteSuccess"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ResourceWriteFailureEventName = "Microsoft.Resources.ResourceWriteFailure"; + public const string ResourceWriteFailure = "Microsoft.Resources.ResourceWriteFailure"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ResourceWriteCancelEventName = "Microsoft.Resources.ResourceWriteCancel"; + public const string ResourceWriteCancel = "Microsoft.Resources.ResourceWriteCancel"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ResourceDeleteSuccessEventName = "Microsoft.Resources.ResourceDeleteSuccess"; + public const string ResourceDeleteSuccess = "Microsoft.Resources.ResourceDeleteSuccess"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ResourceDeleteFailureEventName = "Microsoft.Resources.ResourceDeleteFailure"; + public const string ResourceDeleteFailure = "Microsoft.Resources.ResourceDeleteFailure"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ResourceDeleteCancelEventName = "Microsoft.Resources.ResourceDeleteCancel"; + public const string ResourceDeleteCancel = "Microsoft.Resources.ResourceDeleteCancel"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ResourceActionSuccessEventName = "Microsoft.Resources.ResourceActionSuccess"; + public const string ResourceActionSuccess = "Microsoft.Resources.ResourceActionSuccess"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ResourceActionFailureEventName = "Microsoft.Resources.ResourceActionFailure"; + public const string ResourceActionFailure = "Microsoft.Resources.ResourceActionFailure"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ResourceActionCancelEventName = "Microsoft.Resources.ResourceActionCancel"; + public const string ResourceActionCancel = "Microsoft.Resources.ResourceActionCancel"; #endregion #region ServiceBus events @@ -490,13 +490,13 @@ public static class SystemEventMappings /// The value of the Event Type stored in and for the /// system event. /// - public const string ServiceBusActiveMessagesAvailableWithNoListenersEventName = "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners"; + public const string ServiceBusActiveMessagesAvailableWithNoListeners = "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string ServiceBusDeadletterMessagesAvailableWithNoListenerEventName = "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener"; + public const string ServiceBusDeadletterMessagesAvailableWithNoListener = "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener"; #endregion #region Storage events @@ -504,43 +504,43 @@ public static class SystemEventMappings /// The value of the Event Type stored in and for the /// system event. /// - public const string StorageBlobCreatedEventName = "Microsoft.Storage.BlobCreated"; + public const string StorageBlobCreated = "Microsoft.Storage.BlobCreated"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string StorageBlobDeletedEventName = "Microsoft.Storage.BlobDeleted"; + public const string StorageBlobDeleted = "Microsoft.Storage.BlobDeleted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string StorageBlobRenamedEventName = "Microsoft.Storage.BlobRenamed"; + public const string StorageBlobRenamed = "Microsoft.Storage.BlobRenamed"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string StorageDirectoryCreatedEventName = "Microsoft.Storage.DirectoryCreated"; + public const string StorageDirectoryCreated = "Microsoft.Storage.DirectoryCreated"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string StorageDirectoryDeletedEventName = "Microsoft.Storage.DirectoryDeleted"; + public const string StorageDirectoryDeleted = "Microsoft.Storage.DirectoryDeleted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string StorageDirectoryRenamedEventName = "Microsoft.Storage.DirectoryRenamed"; + public const string StorageDirectoryRenamed = "Microsoft.Storage.DirectoryRenamed"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string StorageLifecyclePolicyCompletedEventName = "Microsoft.Storage.LifecyclePolicyCompleted"; + public const string StorageLifecyclePolicyCompleted = "Microsoft.Storage.LifecyclePolicyCompleted"; #endregion #region App Service @@ -548,79 +548,79 @@ public static class SystemEventMappings /// The value of the Event Type stored in and for the /// system event. /// - public const string WebAppUpdatedEventName = "Microsoft.Web.AppUpdated"; + public const string WebAppUpdated = "Microsoft.Web.AppUpdated"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string WebBackupOperationStartedEventName = "Microsoft.Web.BackupOperationStarted"; + public const string WebBackupOperationStarted = "Microsoft.Web.BackupOperationStarted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string WebBackupOperationCompletedEventName = "Microsoft.Web.BackupOperationCompleted"; + public const string WebBackupOperationCompleted = "Microsoft.Web.BackupOperationCompleted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string WebBackupOperationFailedEventName = "Microsoft.Web.BackupOperationFailed"; + public const string WebBackupOperationFailed = "Microsoft.Web.BackupOperationFailed"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string WebRestoreOperationStartedEventName = "Microsoft.Web.RestoreOperationStarted"; + public const string WebRestoreOperationStarted = "Microsoft.Web.RestoreOperationStarted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string WebRestoreOperationCompletedEventName = "Microsoft.Web.RestoreOperationCompleted"; + public const string WebRestoreOperationCompleted = "Microsoft.Web.RestoreOperationCompleted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string WebRestoreOperationFailedEventName = "Microsoft.Web.RestoreOperationFailed"; + public const string WebRestoreOperationFailed = "Microsoft.Web.RestoreOperationFailed"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string WebSlotSwapStartedEventName = "Microsoft.Web.SlotSwapStarted"; + public const string WebSlotSwapStarted = "Microsoft.Web.SlotSwapStarted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string WebSlotSwapCompletedEventName = "Microsoft.Web.SlotSwapCompleted"; + public const string WebSlotSwapCompleted = "Microsoft.Web.SlotSwapCompleted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string WebSlotSwapFailedEventName = "Microsoft.Web.SlotSwapFailed"; + public const string WebSlotSwapFailed = "Microsoft.Web.SlotSwapFailed"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string WebSlotSwapWithPreviewStartedEventName = "Microsoft.Web.SlotSwapWithPreviewStarted"; + public const string WebSlotSwapWithPreviewStarted = "Microsoft.Web.SlotSwapWithPreviewStarted"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string WebSlotSwapWithPreviewCancelledEventName = "Microsoft.Web.SlotSwapWithPreviewCancelled"; + public const string WebSlotSwapWithPreviewCancelled = "Microsoft.Web.SlotSwapWithPreviewCancelled"; /// /// The value of the Event Type stored in and for the /// system event. /// - public const string WebAppServicePlanUpdatedEventName = "Microsoft.Web.AppServicePlanUpdated"; + public const string WebAppServicePlanUpdated = "Microsoft.Web.AppServicePlanUpdated"; #endregion } } diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs index 4f9c91070bd8..683e96337ccc 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs @@ -26,7 +26,7 @@ public void ParsesEventGridEnvelope() Assert.AreEqual("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", egEvent.Topic); Assert.AreEqual("2d1781af-3a4c-4d7c-bd0c-e34b19da4e66", egEvent.Id); Assert.AreEqual("mySubject", egEvent.Subject); - Assert.AreEqual(SystemEventMappings.EventGridSubscriptionValidationEventName, egEvent.EventType); + Assert.AreEqual(SystemEventNames.EventGridSubscriptionValidation, egEvent.EventType); Assert.AreEqual(DateTimeOffset.Parse("2018-01-25T22:12:19.4556811Z"), egEvent.EventTime); Assert.AreEqual("1", egEvent.DataVersion); } @@ -43,7 +43,7 @@ public void ConsumeStorageBlobDeletedEventWithExtraProperty() { switch (egEvent.EventType) { - case SystemEventMappings.StorageBlobDeletedEventName: + case SystemEventNames.StorageBlobDeleted: StorageBlobDeletedEventData blobDeleted = (StorageBlobDeletedEventData)egEvent.AsSystemEventData(); Assert.AreEqual("https://example.blob.core.windows.net/testcontainer/testfile.txt", blobDeleted.Url); Assert.AreEqual("/subscriptions/id/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount", egEvent.Topic); @@ -64,7 +64,7 @@ public void ConsumeEventNotWrappedInAnArray() { switch (egEvent.EventType) { - case SystemEventMappings.StorageBlobDeletedEventName: + case SystemEventNames.StorageBlobDeleted: StorageBlobDeletedEventData blobDeleted = (StorageBlobDeletedEventData)egEvent.AsSystemEventData(); Assert.AreEqual("https://example.blob.core.windows.net/testcontainer/testfile.txt", blobDeleted.Url); break; @@ -88,11 +88,11 @@ public void ConsumeMultipleEventsInSameBatch() { switch (egEvent.EventType) { - case SystemEventMappings.StorageBlobCreatedEventName: + case SystemEventNames.StorageBlobCreated: StorageBlobCreatedEventData blobCreated = (StorageBlobCreatedEventData)egEvent.AsSystemEventData(); Assert.AreEqual("https://myaccount.blob.core.windows.net/testcontainer/file1.txt", blobCreated.Url); break; - case SystemEventMappings.StorageBlobDeletedEventName: + case SystemEventNames.StorageBlobDeleted: StorageBlobDeletedEventData blobDeleted = (StorageBlobDeletedEventData)egEvent.AsSystemEventData(); Assert.AreEqual("https://example.blob.core.windows.net/testcontainer/testfile.txt", blobDeleted.Url); break; @@ -110,7 +110,7 @@ public void ConsumeEventUsingBinaryDataExtensionMethod() Assert.NotNull(egEvent); switch (egEvent.EventType) { - case SystemEventMappings.StorageBlobDeletedEventName: + case SystemEventNames.StorageBlobDeleted: StorageBlobDeletedEventData blobDeleted = (StorageBlobDeletedEventData)egEvent.AsSystemEventData(); Assert.AreEqual("https://example.blob.core.windows.net/testcontainer/testfile.txt", blobDeleted.Url); break; @@ -127,13 +127,13 @@ public void EGEventAsSystemEventDataThrowsWhenCalledWithoutParse() }); EventGridEvent egEvent = new EventGridEvent( + "/contoso/items", + "Contoso.Items.ItemReceived", + "1", new ContosoItemReceivedEventData() { ItemSku = "512d38b6-c7b8-40c8-89fe-f46f9e9622b6" - }, - "/contoso/items", - "Contoso.Items.ItemReceived", - "1"); + }); Assert.That(() => egEvent.GetData(customSerializer), Throws.InstanceOf()); @@ -1402,7 +1402,7 @@ public void ParsesCloudEventEnvelope() Assert.AreEqual("994bc3f8-c90c-6fc3-9e83-6783db2221d5", cloudEvent.Id); Assert.AreEqual("Subject-0", cloudEvent.Source); - Assert.AreEqual(SystemEventMappings.StorageBlobDeletedEventName, cloudEvent.Type); + Assert.AreEqual(SystemEventNames.StorageBlobDeleted, cloudEvent.Type); Assert.AreEqual("text/plain", cloudEvent.DataContentType); Assert.AreEqual("subject", cloudEvent.Subject); Assert.AreEqual("1.0", cloudEvent.DataSchema); @@ -1419,7 +1419,7 @@ public void ConsumeCloudEventsWithAdditionalProperties() CloudEvent[] events = CloudEvent.Parse(requestContent); Assert.NotNull(events); - if (events[0].Type == SystemEventMappings.StorageBlobDeletedEventName) + if (events[0].Type == SystemEventNames.StorageBlobDeleted) { StorageBlobDeletedEventData eventData = events[0].GetData(); Assert.AreEqual("https://example.blob.core.windows.net/testcontainer/testfile.txt", eventData.Url); @@ -1439,7 +1439,7 @@ public void ConsumeCloudEventUsingBinaryDataExtensionMethod() Assert.NotNull(cloudEvent); switch (cloudEvent.Type) { - case SystemEventMappings.StorageBlobDeletedEventName: + case SystemEventNames.StorageBlobDeleted: StorageBlobDeletedEventData blobDeleted =cloudEvent.GetData(); Assert.AreEqual("https://example.blob.core.windows.net/testcontainer/testfile.txt", blobDeleted.Url); break; @@ -1454,7 +1454,7 @@ public void ConsumeCloudEventNotWrappedInAnArray() CloudEvent[] events = CloudEvent.Parse(requestContent); Assert.NotNull(events); - if (events[0].Type == SystemEventMappings.StorageBlobDeletedEventName) + if (events[0].Type == SystemEventNames.StorageBlobDeleted) { StorageBlobDeletedEventData eventData = events[0].GetData(); Assert.AreEqual("https://example.blob.core.windows.net/testcontainer/testfile.txt", eventData.Url); diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/EventGridClientLiveTests.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/EventGridClientLiveTests.cs index 28f394a0c4fc..ae7b7e330fcb 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/EventGridClientLiveTests.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/EventGridClientLiveTests.cs @@ -53,10 +53,10 @@ public async Task CanPublishEventWithCustomObjectPayload() { eventsList.Add( new EventGridEvent( - new TestPayload("name", i), $"Subject-{i}", "Microsoft.MockPublisher.TestEvent", - "1.0") + "1.0", + new TestPayload("name", i)) { Id = Recording.Random.NewGuid().ToString(), EventTime = Recording.Now @@ -81,10 +81,10 @@ public async Task CanPublishEventToDomain() for (int i = 0; i < 10; i++) { EventGridEvent newEGEvent = new EventGridEvent( - "hello", $"Subject-{i}", "Microsoft.MockPublisher.TestEvent", - "1.0") + "1.0", + "hello") { Id = Recording.Random.NewGuid().ToString(), EventTime = Recording.Now @@ -306,10 +306,10 @@ public async Task CanPublishCustomEvent() [Test] public async Task CanPublishEventUsingSAS() { - string sasToken = EventGridPublisherClient.BuildSharedAccessSignature( + var builder = new EventGridSasBuilder( new Uri(TestEnvironment.TopicHost), - DateTimeOffset.UtcNow.AddMinutes(60), - new AzureKeyCredential(TestEnvironment.TopicKey)); + DateTimeOffset.UtcNow.AddMinutes(60)); + string sasToken = builder.GenerateSas(new AzureKeyCredential(TestEnvironment.TopicKey)); EventGridPublisherClient sasTokenClient = InstrumentClient( new EventGridPublisherClient( @@ -345,10 +345,10 @@ private IList GetEventsList() { eventsList.Add( new EventGridEvent( - "hello", $"Subject-{i}", "Microsoft.MockPublisher.TestEvent", - "1.0") + "1.0", + "hello") { Id = Recording.Random.NewGuid().ToString(), EventTime = Recording.Now diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/EventGridEventTests.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/EventGridEventTests.cs index 5a4250206d55..86a60e92323c 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/EventGridEventTests.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/EventGridEventTests.cs @@ -33,15 +33,15 @@ public async Task SerializesExpectedProperties_BaseType() new AzureKeyCredential("fakeKey"), options); var egEvent = new EventGridEvent( + "record", + "Microsoft.MockPublisher.TestEvent", + "TestPayload", new DerivedTestPayload { Name = "name", Age = 10, DerivedProperty = 5 }, - "record", - "Microsoft.MockPublisher.TestEvent", - "TestPayload", typeof(TestPayload)); // since the data has not yet been serialized (CloudEvent not constructed from Parse method), GetData returns the passed in instance. @@ -76,15 +76,15 @@ public async Task SerializesExpectedProperties_DerivedType() new AzureKeyCredential("fakeKey"), options); var egEvent = new EventGridEvent( + "record", + "Microsoft.MockPublisher.TestEvent", + "TestPayload", new DerivedTestPayload { Name = "name", Age = 10, DerivedProperty = 5 - }, - "record", - "Microsoft.MockPublisher.TestEvent", - "TestPayload"); + }); Assert.AreEqual(5, egEvent.GetData().DerivedProperty); Assert.AreEqual(5, egEvent.GetData().ToObjectFromJson().DerivedProperty); diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/Samples/Sample1_SendEventsToTopicAndDomain.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/Samples/Sample1_SendEventsToTopicAndDomain.cs index f9308f18b172..07808a3bd4c2 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/Samples/Sample1_SendEventsToTopicAndDomain.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/Samples/Sample1_SendEventsToTopicAndDomain.cs @@ -36,10 +36,10 @@ public async Task SendEventGridEventsToTopic() List eventsList = new List { new EventGridEvent( - "This is the event data", "ExampleEventSubject", "Example.EventType", - "1.0") + "1.0", + "This is the event data") }; // Send the events @@ -118,10 +118,10 @@ public async Task SendEventsToDomain() List eventsList = new List { new EventGridEvent( - "This is the event data", "ExampleEventSubject", "Example.EventType", - "1.0") + "1.0", + "This is the event data") { Topic = "MyTopic" } diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/Samples/Sample2_ParseAndDeserializeEvents.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/Samples/Sample2_ParseAndDeserializeEvents.cs index 934eddb23d15..79a126174e5e 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/Samples/Sample2_ParseAndDeserializeEvents.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/Samples/Sample2_ParseAndDeserializeEvents.cs @@ -101,7 +101,7 @@ public async Task GenericReceiveAndDeserializeEventGridEvents() TestPayload testPayload = await cloudEvent.GetDataAsync(myCustomSerializer); Console.WriteLine(testPayload.Name); break; - case SystemEventMappings.StorageBlobDeletedEventName: + case SystemEventNames.StorageBlobDeleted: // Example for deserializing system events using GetData StorageBlobDeletedEventData blobDeleted = cloudEvent.GetData(); Console.WriteLine(blobDeleted.BlobType); From 148b2f8141d58cc7a022a65d19ff8f1622571221 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Thu, 28 Jan 2021 19:48:12 -0800 Subject: [PATCH 2/3] webjob tests --- .../tests/JobhostEndToEnd.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/eventgrid/Microsoft.Azure.WebJobs.Extensions.EventGrid/tests/JobhostEndToEnd.cs b/sdk/eventgrid/Microsoft.Azure.WebJobs.Extensions.EventGrid/tests/JobhostEndToEnd.cs index 5effa34951c0..0658b842f563 100644 --- a/sdk/eventgrid/Microsoft.Azure.WebJobs.Extensions.EventGrid/tests/JobhostEndToEnd.cs +++ b/sdk/eventgrid/Microsoft.Azure.WebJobs.Extensions.EventGrid/tests/JobhostEndToEnd.cs @@ -366,13 +366,13 @@ public class OutputBindingParams { public void SingleEvent([EventGrid(TopicEndpointUri = "eventgridUri", TopicKeySetting = "eventgridKey")] out EventGridEvent single) { - single = new EventGridEvent("0", "", "", ""); + single = new EventGridEvent("", "", "", data: "0"); } [return: EventGrid(TopicEndpointUri = "eventgridUri", TopicKeySetting = "eventgridKey")] public EventGridEvent SingleReturnEvent() { - return new EventGridEvent("0", "", "", ""); + return new EventGridEvent("", "", "", data: "0"); } public void ArrayEvent([EventGrid(TopicEndpointUri = "eventgridUri", TopicKeySetting = "eventgridKey")] out EventGridEvent[] array) @@ -380,7 +380,7 @@ public void ArrayEvent([EventGrid(TopicEndpointUri = "eventgridUri", TopicKeySet array = new EventGridEvent[5]; for (int i = 0; i < 5; i++) { - array[i] = new EventGridEvent(i.ToString(), "", "", ""); + array[i] = new EventGridEvent("", "", "", data: i.ToString()); } } @@ -388,7 +388,7 @@ public void CollectorEvent([EventGrid(TopicEndpointUri = "eventgridUri", TopicKe { for (int i = 0; i < 4; i++) { - collector.Add(new EventGridEvent(i.ToString(), "", "", "")); + collector.Add(new EventGridEvent("", "", "", data: i.ToString())); } } @@ -396,7 +396,7 @@ public async Task AsyncCollectorEvent([EventGrid(TopicEndpointUri = "eventgridUr { for (int i = 0; i < 7; i++) { - await asyncCollector.AddAsync(new EventGridEvent(i.ToString(), "", "", "")); + await asyncCollector.AddAsync(new EventGridEvent("", "", "", data: i.ToString())); if (i % 3 == 0) { From 37977378ce1f8abbfa5515e4e58ea23fcd045394 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Fri, 29 Jan 2021 11:32:24 -0800 Subject: [PATCH 3/3] Use optional serializer param in GetData methods; revert culture in SAS --- ...zure.Messaging.EventGrid.netstandard2.0.cs | 10 +++---- .../src/Customization/CloudEvent.cs | 29 +++++++------------ .../src/Customization/EventGridEvent.cs | 29 +++++++------------ .../src/Customization/EventGridSasBuilder.cs | 2 +- .../tests/ConsumeEventTests.cs | 1 + 5 files changed, 26 insertions(+), 45 deletions(-) diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs index 35fe266c0de6..1c66e0dfc7f1 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs @@ -20,9 +20,8 @@ public CloudEvent(string source, string type, object data, string dataContentTyp public object AsSystemEventData() { throw null; } public System.BinaryData GetData() { throw null; } public System.Threading.Tasks.Task GetDataAsync() { throw null; } - public System.Threading.Tasks.Task GetDataAsync(Azure.Core.Serialization.ObjectSerializer serializer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public T GetData(Azure.Core.Serialization.ObjectSerializer serializer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public T GetData(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public System.Threading.Tasks.Task GetDataAsync(Azure.Core.Serialization.ObjectSerializer serializer = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public T GetData(Azure.Core.Serialization.ObjectSerializer serializer = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.Messaging.EventGrid.CloudEvent[] Parse(System.BinaryData requestContent) { throw null; } public static Azure.Messaging.EventGrid.CloudEvent[] Parse(string requestContent) { throw null; } } @@ -39,9 +38,8 @@ public EventGridEvent(string subject, string eventType, string dataVersion, obje public object AsSystemEventData() { throw null; } public System.BinaryData GetData() { throw null; } public System.Threading.Tasks.Task GetDataAsync() { throw null; } - public System.Threading.Tasks.Task GetDataAsync(Azure.Core.Serialization.ObjectSerializer serializer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public T GetData(Azure.Core.Serialization.ObjectSerializer serializer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public T GetData(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public System.Threading.Tasks.Task GetDataAsync(Azure.Core.Serialization.ObjectSerializer serializer = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public T GetData(Azure.Core.Serialization.ObjectSerializer serializer = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.Messaging.EventGrid.EventGridEvent[] Parse(System.BinaryData requestContent) { throw null; } public static Azure.Messaging.EventGrid.EventGridEvent[] Parse(string requestContent) { throw null; } } diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/CloudEvent.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/CloudEvent.cs index fb708f55a55d..e5b2c0425b89 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/CloudEvent.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/CloudEvent.cs @@ -167,51 +167,42 @@ public static CloudEvent[] Parse(string requestContent) /// Deserializes the event payload into a specified event type using the provided . /// /// Type of event to deserialize to. - /// Custom serializer used to deserialize the payload. + /// A custom serializer used to deserialize the payload. If not provided, the + /// will be used. /// The cancellation token to use during deserialization. /// Event was not created from CloudEvent.Parse() method. /// Event payload cannot be cast to the specified event type. /// Deserialized payload of the event, cast to the specified type. - public async Task GetDataAsync(ObjectSerializer serializer, CancellationToken cancellationToken = default) + public async Task GetDataAsync(ObjectSerializer serializer = default, CancellationToken cancellationToken = default) { - if (Data != null) + if (Data != null && serializer != null) { throw new InvalidOperationException("Cannot pass in a custom deserializer if event was not created from CloudEvent.Parse(), " + "as event data should already be deserialized and the custom deserializer will not be used."); } - return await GetDataInternal(serializer, true, cancellationToken).ConfigureAwait(false); + return await GetDataInternal(serializer ?? s_jsonSerializer, true, cancellationToken).ConfigureAwait(false); } /// /// Deserializes the event payload into a specified event type using the provided . /// /// Type of event to deserialize to. - /// Custom serializer used to deserialize the payload. + /// A custom serializer used to deserialize the payload. If not provided, the + /// will be used. /// The cancellation token to use during deserialization. /// Event was not created from CloudEvent.Parse() method. /// Event payload cannot be cast to the specified event type. /// Deserialized payload of the event, cast to the specified type. - public T GetData(ObjectSerializer serializer, CancellationToken cancellationToken = default) + public T GetData(ObjectSerializer serializer = default, CancellationToken cancellationToken = default) { - if (Data != null) + if (Data != null && serializer != null) { throw new InvalidOperationException("Cannot pass in a custom deserializer if event was not created from CloudEvent.Parse(), " + "as event data should already be deserialized and the custom deserializer will not be used."); } - return GetDataInternal(serializer, false, cancellationToken).EnsureCompleted(); + return GetDataInternal(serializer ?? s_jsonSerializer, false, cancellationToken).EnsureCompleted(); } - /// - /// Deserializes the event payload into a specified event type using the provided . - /// - /// Type of event to deserialize to. - /// The cancellation token to use during deserialization. - /// Event was not created from CloudEvent.Parse() method. - /// Event payload cannot be cast to the specified event type. - /// Deserialized payload of the event, cast to the specified type. - public T GetData(CancellationToken cancellationToken = default) - => GetDataInternal(s_jsonSerializer, false, cancellationToken).EnsureCompleted(); - private async Task GetDataInternal(ObjectSerializer serializer, bool async, CancellationToken cancellationToken = default) { Argument.AssertNotNull(serializer, nameof(serializer)); diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridEvent.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridEvent.cs index 84432f6cf494..0993ffc40a96 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridEvent.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridEvent.cs @@ -133,51 +133,42 @@ public static EventGridEvent[] Parse(string requestContent) /// Deserializes the event payload into a specified event type using the provided . /// /// Type of event to deserialize to. - /// Custom serializer used to deserialize the payload. + /// A custom serializer used to deserialize the payload. If not provided, the + /// will be used. /// The cancellation token to use during deserialization. /// Event was not created from EventGridEvent.Parse() method. /// Event payload cannot be cast to the specified event type. /// Deserialized payload of the event, cast to the specified type. - public async Task GetDataAsync(ObjectSerializer serializer, CancellationToken cancellationToken = default) + public async Task GetDataAsync(ObjectSerializer serializer = default, CancellationToken cancellationToken = default) { - if (Data != null) + if (Data != null && serializer != null) { throw new InvalidOperationException("Cannot pass in a custom deserializer if event was not created from EventGridEvent.Parse(), " + "as event data should already be deserialized and the custom deserializer will not be used."); } - return await GetDataInternal(serializer, true, cancellationToken).ConfigureAwait(false); + return await GetDataInternal(serializer ?? s_jsonSerializer, true, cancellationToken).ConfigureAwait(false); } /// /// Deserializes the event payload into a specified event type using the provided . /// /// Type of event to deserialize to. - /// Custom serializer used to deserialize the payload. + /// A custom serializer used to deserialize the payload. If not provided, the + /// will be used. /// The cancellation token to use during deserialization. /// Event was not created from EventGridEvent.Parse() method. /// Event payload cannot be cast to the specified event type. /// Deserialized payload of the event, cast to the specified type. - public T GetData(ObjectSerializer serializer, CancellationToken cancellationToken = default) + public T GetData(ObjectSerializer serializer = default, CancellationToken cancellationToken = default) { - if (Data != null) + if (Data != null && serializer != null) { throw new InvalidOperationException("Cannot pass in a custom deserializer if event was not created from EventGridEvent.Parse(), " + "as event data should already be deserialized and the custom deserializer will not be used."); } - return GetDataInternal(serializer, false, cancellationToken).EnsureCompleted(); + return GetDataInternal(serializer ?? s_jsonSerializer, false, cancellationToken).EnsureCompleted(); } - /// - /// Deserializes the event payload into a specified event type using the provided . - /// - /// Type of event to deserialize to. - /// The cancellation token to use during deserialization. - /// Event was not created from EventGridEvent.Parse() method. - /// Event payload cannot be cast to the specified event type. - /// Deserialized payload of the event, cast to the specified type. - public T GetData(CancellationToken cancellationToken = default) - => GetDataInternal(s_jsonSerializer, false, cancellationToken).EnsureCompleted(); - private async Task GetDataInternal(ObjectSerializer serializer, bool async, CancellationToken cancellationToken = default) { Argument.AssertNotNull(serializer, nameof(serializer)); diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridSasBuilder.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridSasBuilder.cs index f1a7244dd67b..22c10c742d98 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridSasBuilder.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/EventGridSasBuilder.cs @@ -75,7 +75,7 @@ public string GenerateSas(AzureKeyCredential key) uriBuilder.Reset(Endpoint); uriBuilder.AppendQuery("api-version", ApiVersion.GetVersionString(), true); string encodedResource = HttpUtility.UrlEncode(uriBuilder.ToString()); - var encodedExpirationUtc = HttpUtility.UrlEncode(ExpiresOn.ToString(CultureInfo.InvariantCulture)); + var encodedExpirationUtc = HttpUtility.UrlEncode(ExpiresOn.ToString(CultureInfo.CreateSpecificCulture("en-US"))); string unsignedSas = $"{Resource}={encodedResource}&{Expiration}={encodedExpirationUtc}"; using (var hmac = new HMACSHA256(Convert.FromBase64String(key.Key))) diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs index 683e96337ccc..8ca70d610b02 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/tests/ConsumeEventTests.cs @@ -407,6 +407,7 @@ public void ConsumeEventGridSubscriptionValidationEvent() Assert.NotNull(events); Assert.True(events[0].AsSystemEventData() is SubscriptionValidationEventData); + Assert.True(events[0].GetData() is SubscriptionValidationEventData); SubscriptionValidationEventData eventData = (SubscriptionValidationEventData)events[0].AsSystemEventData(); Assert.AreEqual("512d38b6-c7b8-40c8-89fe-f46f9e9622b6", eventData.ValidationCode); }