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://
and here is the error message:
The attempt to validate the provided endpoint https://
Expected behavior
I want it to work
Environment summary
shell command from terraform script
Additional context
What am I missing?
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jfggdl
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jfggdl
@dwhanger, thank you for raising this question. We are trying to reproduce your problem and we should be able to provide you with our findings or actual way to create a subscription.
Thanks for reporting it. From the description, it seems that the endpoint info is not in the correct/expected format for EventTrigger function.
The provided endpoint is
https://.azurewebsites.net/runtime/webhooks/EventGrid?functionName=
while the expected format should be something like this: https://{FuncAppName}.azurewebsites.net/runtime/webhooks/EventGrid?functionName={EventGridTriggerFunctName}&code={Key}
The provided endpoint is missing the function app name, function name and the key parts. To get this info please navigate to your function app --> Event Triggered function --> Integrate --> Event Grid Subscription URL --> Copy the context of the text box and use it in the az eventgrid event-subscription create command.
here is a sample of working cli command:
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}
Please let us know if you are still hitting any issue. thanks
yeah, unfortunately, when I posted this originally I did not choose the { } and instead used less than and greater than signs which got "filtered"....
let me try with these paramenters.....one question though, how do I get the {Key} programmatically ?
I don't want to have to navigate to the portal and have any manual steps....
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?
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.
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.
Adding Function servide tag to provide a way for customer to get the key programmatically as this is function app issue and not event grid specific issue (We provided a workaround through the portal but customer is looking for programmatic way to get this info).
Hi Ahamad,
This is not a FunctionApp issue. I am able to get the key programmatically. The issue is with the az cli command. The command should not complain about validation hand shake, as the subscriber is a function with EventGridTrigger binding.
Expected: The az cli command should succeed and not ask for validation handshake.
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}
Hey @rcreddy435 and @dwhanger since this was opened, we also released support for Functions as a 1st classed destination type. With this, rather than pointing to the function URI & explicitly giving the key, you can just point to the Function ARM ID like so:
az eventgrid event-subscription create --name es1
--source-resource-id
/subscriptions/{SubID}/resourceGroups/{RG}/providers/Microsoft.EventGrid/topics/topic1
--endpoint /subscriptions/{SubID}/resourceGroups/{RG}/providers/Microsoft.Web/sites/{fun
ctionappname}/functions/{functionname}
Event Grid will then take care of doing a RBAC check to ensure you have access to publish to the function, getting the function key, and setting up the event subscription. This also has the added benefit of Event Grid taking care of keeping the key up-to-date if you roll keys etc.
To use this in CLI, just make sure you have the latest Event Grid CLI extension added az extension add --name eventgrid
and if you had an older version of the extension, uninstall it before installing the newest version of the extension (extension version 0.4.4).
Hello @rcreddy435 … I am referring to the original issue reported by @dwhanger as the request is clearly stated he needed a way to get this key programmatically. If you can share how you get it programmatically it will be great.
As for the issue you are reported, this is different than the original one and we need additional info to investigate. Can you please raise a support ticket with the following information (since the info include your subscription Id, the GitHub issue might not be a good place to share this sensitive info):
thanks
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.
@banisadr - I am having the same issue as @dwhanger when using the eventgrid extension you mentioned. I do get this warning which shows that the eventgrid extension is altering the command:
The behavior of this command has been altered by the following extension: eventgrid
If the provided endpoint does not support subscription validation handshake, navigate to the validation URL that you receive in the subscription validation event, in order to complete the
event subscription creation or update. For more details, please visit http://aka.ms/esvalidation
@rcreddy435 - I'm having the same issue as you with the az command but as @ahamad-MS mentioned, that is a separate issue from what the OP submitted. Have you entered a github issue for the error you are encountering?
Hi Mike,
I haven't created an issue.
Thanks
Rama
On Mon, Dec 16, 2019 at 10:30 AM AlphaCreative-Mike <
[email protected]> wrote:
@rcreddy435 https://github.com/rcreddy435 - I'm having he same issue as
you with the az command but as @ahamad-MS https://github.com/ahamad-MS
mentioned, that is a separate issue from what the OP submitted. Have you
entered a github issue for the error you are encountering?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Azure/azure-cli/issues/10879?email_source=notifications&email_token=AEL5KQUVQHAW4CPDLRREFE3QY6UL5A5CNFSM4JBSTVZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG7JAXY#issuecomment-566136927,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AEL5KQXVU2DYBFIHLQHJL3DQY6UL5ANCNFSM4JBSTVZA
.
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!!!
@banisadr : i have the eventgrid extension "0.4.3". I will update to "0.4.4" and try again.
@rcreddy435 - Do you mind sharing how you got the key programmatically? I've tried several examples online but the subscription fails. If I hardcode the key it works.
Task: create Storage Account Event Subscription to trigger Azure Function
The problem in PowerShell with
az eventgrid event-subscription create
is that endpoint is URL with '&' symbol. The same command works on: shell.azure.com
.
Tried escaping it <- does not help
local PowerShell
PS C:\> $triggerEndpoint
https://[webAppName].azurewebsites.net/runtime/webhooks/EventGrid?functionName=[triggerName]&code=[key]
PS C:\> az eventgrid event-subscription create --debug --name $eventSubscriptionName --source-resource-id $storageid.id --endpoint $triggerEndpoint
Command arguments: ['eventgrid', 'event-subscription', 'create', '--debug', '--name', '[eventName]', '--source-resource-id', '/subscriptions/[subId]/resourceGroups/[rsGroup]/providers/Microsoft.Storage/storageAccounts/[accountName]',
'--endpoint', 'https://[webAppName].azurewebsites.net/runtime/webhooks/EventGrid?functionName=[triggerName]']
...other output
Argument endpoint drops code query parameter and it does become invalid endpoint.
For getting more information:
shell.azure.com CorrelationId: 3b65c124-0f63-4789-8e9e-b38528133d35
local PowerShell CorrelationId: 3b8ae7ea-bb49-407b-a137-dd9343678294
Ps. running this command with VS Code installed is really funny :)
If someone is having this problem I would suggest using this:
New-AzEventGridSubscription
@rcreddy435 - Do you mind sharing how you got the key programmatically? I've tried several examples online but the subscription fails. If I hardcode the key it works.
@AlphaCreative-Mike : Did you check this url? https://markheath.net/post/managing-azure-functions-keys-2
Clarifying above
az eventgrid event-subscription create --name es1
--source-resource-id
/subscriptions/{SubID}/resourceGroups/{RG}/providers/Microsoft.EventGrid/topics/topic1
--endpoint /subscriptions/{SubID}/resourceGroups/{RG}/providers/Microsoft.Web/sites/{fun
ctionappname}/functions/{functionname}
As of v0.4.8 this command works IF you add --endpoint-type azurefunction
.
cool...I will try that out! thanks!
@dwhanger Can you please confirm that this is working for you as well? Thanks.
@anthonychu - It's not working for me.
I'm getting "az eventgrid event-subscription create: 'FunctionApp' is not a valid value for '--endpoint-type'. See 'az eventgrid event-subscription create --help'"
Here is my az --version output:
`azure-cli 2.5.1
command-modules-nspkg 2.0.3
core 2.5.1
nspkg 3.0.4
telemetry 1.0.4
Extensions:
eventgrid 0.4.8
front-door 1.0.6`
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
, not functionapp
. I also added a link to the documentation.
I can confirm that the using resources for both the source and subscriber and endpoint type worked for me. Somebody really really needs to get this out into the current az client install. I spent days with this exact issue, worked through getting keys, got past the '&' in the url from powershell and always got an invalid response result. Also before adding the extension, even manually added subscriptions didn't show up with az eventgrid event-subscription list --<all the options tried>
. With the extension update, everything works but I get a warning with every command the the command has been overridden with the extension.
one quick followup question. where do I go with an issue with the eventgridtrigger attribute on a function? The funtion.json it generates does not include the required direction parameter set to "in" and a warning shows up on every function in the project in the azure portal. It does work though
Most helpful comment
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!