Open douglaswaights opened 5 years ago
Just to add some further information this is the code i'm using below.
The error i'm getting is an invalid arm id.
I'm confused as the storage account exists (first arm id) and i've also manually created the event hub namespace and hub (2nd arm id is the namespace id)... so both exist...
func getEventSubscriptionsClient() eventgrid.EventSubscriptionsClient {
eventgridClient := eventgrid.NewEventSubscriptionsClient(subscriptionID)
eventgridClient.Authorizer, _ = getAuthorizer()
eventgridClient.AddToUserAgent(userAgent)
return eventgridClient
}
func createEventSubscription(ctx context.Context) (eventgrid.EventSubscription, error) {
client := getEventSubscriptionsClient()
future, err := client.CreateOrUpdate(ctx, "/subscriptions/redacted/resourceGroups/rubbish1/providers/Microsoft.Storage/storageAccounts/abcdefnort", "mysubscription",
eventgrid.EventSubscription{
EventSubscriptionProperties: &eventgrid.EventSubscriptionProperties{
Destination: &eventgrid.EventHubEventSubscriptionDestination{
EndpointType: eventgrid.EndpointTypeEventHub,
EventHubEventSubscriptionDestinationProperties: &eventgrid.EventHubEventSubscriptionDestinationProperties{
ResourceID: to.StringPtr("/subscriptions/redacted/resourceGroups/rubbish1/providers/Microsoft.EventHub/namespaces/douglas"),
},
},
},
},
)
if err != nil {
//return s, fmt.Errorf(fmt.Sprintf(errorPrefix, err))
}
err = future.WaitForCompletionRef(ctx, client.Client)
if err != nil {
//return s, fmt.Errorf(fmt.Sprintf(errorPrefix, fmt.Sprintf("cannot get the storage account create future response: %v", err)))
}
return future.Result(client)
}
This is solved. I was using the resource id of the event hub namespace rather than the resource id of the hub itself.
Feel free to close the issue . I still think a sample would be beneficial so i'll leave the issue open for now.
Thanks
Hi,
Is there a sample anywhere that shows how to create an event grid subscription on a blob storage account? I would like to then make the end point topic an event hub.
There are samples for event hubs but its complicated to wire up the event subscription on a blob storage account and i just keep getting 400 bad request errors.
Thanks Doug