Сетка событий Azure - создайте подписку с очередью хранилища Azure как endpointType. - PullRequest
0 голосов
/ 02 июля 2018

Мы можем подписаться на тему сетки событий через очередь хранилища, используя Azure CLI, как упомянуто:

az eventgrid event-subscription create \
  --topic-name demotopic \
  -g myResourceGroup \
  --name eventsub1 \
  --endpoint-type storagequeue \
  --endpoint <storage-queue-url>

При использовании Microsoft.Azure.Management.EventGrid:

EventSubscription eventSubscription = new EventSubscription()
    {
        Destination = new WebHookEventSubscriptionDestination()
        {
             EndpointUrl = endpointUrl
        },
        // The below are all optional settings
        EventDeliverySchema = EventDeliverySchema.EventGridSchema,
        Filter = new EventSubscriptionFilter()
        {
             // By default, "All" event types are included
             IsSubjectCaseSensitive = false,
             SubjectBeginsWith = "",
             SubjectEndsWith = ""
        }

   };

Я не получаю никаких свойств или методов для установки типа конечной точки и конечной точки, как указано в команде CLI.

Может кто-нибудь помочь мне, как я могу установить тип конечной точки в качестве хранилища, используя библиотеку c # nuget

Ответы [ 2 ]

0 голосов
/ 02 июля 2018

Вот пример C # для использования очереди хранения в качестве места назначения в Microsoft.Azure.Management.EventGrid 2.0.0-preview:

С https://github.com/Azure-Samples/event-grid-dotnet-publish-consume-events/blob/master/EGManageArmEventSubscriptions/EGManageArmEventSubscriptions/Program.cs:

    EventSubscription eventSubscription = new EventSubscription()
    {
        Destination = new StorageQueueEventSubscriptionDestination()
        {
            ResourceId = StorageAccountId,
            QueueName = QueueName
        },

        // The below are all optional settings
        EventDeliverySchema = EventDeliverySchema.EventGridSchema,
        Filter = new EventSubscriptionFilter()
        {
            IsSubjectCaseSensitive = false,
            SubjectBeginsWith = "",
            SubjectEndsWith = ""
        }
    };
0 голосов
/ 02 июля 2018

вы должны использовать следующий класс:

    [JsonObject("StorageQueue"), JsonTransformation]
    public class StorageQueueEventSubscriptionDestination : EventSubscriptionDestination
    {
        // Methods
        public StorageQueueEventSubscriptionDestination();
        public StorageQueueEventSubscriptionDestination(string resourceId = new string(), string queueName = new string());

        // Properties
        [JsonProperty(PropertyName="properties.queueName")]
        public string QueueName { get; set; }
        [JsonProperty(PropertyName="properties.resourceId")]
        public string ResourceId { get; set; }
    }

из Microsoft.Azure.Management.EventGrid 2.0.0-preview

Кроме того, в этом предварительном просмотре можно указать свойства DeadLetterDestination и RetryPolicy .

Для DeadLetterDestination используйте следующий класс:

    [JsonObject("StorageBlob"), JsonTransformation]
    public class StorageBlobDeadLetterDestination : DeadLetterDestination
    {
        // Methods
        public StorageBlobDeadLetterDestination();
        public StorageBlobDeadLetterDestination(string resourceId = new string(), string blobContainerName = new string());

        // Properties
        [JsonProperty(PropertyName="properties.blobContainerName")]
        public string BlobContainerName { get; set; }
        [JsonProperty(PropertyName="properties.resourceId")]
        public string ResourceId { get; set; }
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...