Reputation: 2071
We can subscribe to an event grid topic via a storage queue using Azure CLI as mentioned:
az eventgrid event-subscription create \
--topic-name demotopic \
-g myResourceGroup \
--name eventsub1 \
--endpoint-type storagequeue \
--endpoint <storage-queue-url>
When using the 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 = ""
}
};
I am not getting any properties or methods to set the endpoint-type and endpoint as mentioned in the CLI command.
Can anyone help me how I can set the endpoint-type as storagequeue using the c# nuget library
Upvotes: 1
Views: 869
Reputation: 301
Here's the C# sample for using a storage queue as a destination in Microsoft.Azure.Management.EventGrid 2.0.0-preview:
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 = ""
}
};
Upvotes: 1
Reputation: 8235
you should use the following class:
[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; }
}
from Microsoft.Azure.Management.EventGrid 2.0.0-preview
Also, in this preview can be populated a DeadLetterDestination and RetryPolicy properties.
For DeadLetterDestination use the following class:
[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; }
}
Upvotes: 1