azure-cli: az eventgrid event-subscription create fails...
az feedback
auto-generates most of the information requested below, as of CLI version 2.0.62
Describe the bug I can’t get the az eventgrid event-subscription create command to work. Here is, to the best of my ability to read and consume the documentation, my best guess:
az eventgrid event-subscription create --name EndPointCheckerDynatrace --endpoint ‘https://<url>.azurewebsites.net/runtime/webhooks/EventGrid?functionName=<function name>’ --endpoint-type webhook --subject-begins-with Dynatrace --subject-case-sensitive false --event-delivery-schema eventgridschema --labels functions-endpointtypedynatrace --source-resource-id ‘/subscriptions/xxxxx/resourceGroups/<resource group name>/providers/Microsoft.EventGrid/topics/<topic name>’ --subscription xxxxxx
and here is the error message:
The attempt to validate the provided endpoint https://<url>.azurewebsites.net/runtime/webhooks/EventGrid failed. For more details, visit https://aka.ms/esvalidation.
Expected behavior I want it to work
Environment summary shell command from terraform script
Additional context What am I missing?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 33 (6 by maintainers)
Yes! I can confirm that it works! But, you have to use the --endpoint-type azurefunction as opposed to FunctionApp as stated above. There doesn’t seem to be documentation yet on this that I can find but the commandline help on the command has the info about using ‘azurefunction’. Also, once you have this, he --endpoint needs to be adjusted to point at the resource id of the function which I was able to determine with http://resources.azure.com portal. Once that is done, it works great!
I corrected my comment: the endpoint type is
azurefunction
, notfunctionapp
. I also added a link to the documentation.@dwhanger Can you please confirm that this is working for you as well? Thanks.
Clarifying above
As of v0.4.8 this command works IF you add
--endpoint-type azurefunction
.@AlphaCreative-Mike : Did you check this url? https://markheath.net/post/managing-azure-functions-keys-2
btw, @banisadr, the Powershell command does work…it is just cumbersome given that I have to go to the portal after the deploy, find the function app, and copy paste the eventgrid_extension key into a powershell script that I run manually after the fact. Less than ideal for an infrastructure as code automated approach…this needs attention!!!
Hi @banisadr, thanks for your response! I tried the az eventgrid event-subscription form of the command like you have above but I get this back: ‘Invalid event subscription request: Supplied URL is invalid. It cannot be null or empty and should be a proper HTTPS URL like https://www.example.com.’ I have the eventgrid extension installed at version 0.4.4…that was already the case. What am I doing incorrectly? Thanks.
I am having the similar issue. The endpoint does support subscription validation handshake as it is a function with EventGridTrigger binding. Even after passing function name and key, az cli command is throwing the error. “The attempt to validate the provided endpoint https://{functionappname}.azurewebsites.net/runtime/webhooks/eventgrid failed. …”
But same is working with Azure powershell command New-AzEventGridSubscription without complaining about validation.
Thanks, Rama.
hello…given this:
az eventgrid event-subscription create --source-resource-id /subscriptions/{XXXXXX}/resourceGroups/{RgName}/providers/Microsoft.EventGrid/topics/{TopicName} -n {EventSubscriptionName} --endpoint-type webhook --endpoint https://{FuncAppName}.azurewebsites.net/runtime/webhooks/EventGrid?functionName={EventGridTriggerFunctName}&code={Key}
…how do I get the {Key} programmatically so I can pass it in when I register the function without having to go to the portal UI interface? Surely I can’t be the first person wanting to do this…
Thanks.
so, this can probably work as suggested if I have a way of programmatically getting the code so that I can send that in when I register the function to handle the eventgrid events…any suggestions on how to do that?