MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.2k stars 21.35k forks source link

Create subscription sample is not working #48874

Open mregni opened 4 years ago

mregni commented 4 years ago

The sample for V2 and higher for creating a subscription via the CLI is not working anymore. If the command is used, the cli return following error "az eventgrid: 'resource' is not in the 'az eventgrid' command group. See 'az eventgrid --help'."


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

mike-urnun-msft commented 4 years ago

@mregni Thank you for your feedback! We will review and update as appropriate.

mike-urnun-msft commented 4 years ago

@mregni Thanks again for your feedback! It looks like the Portal experience has changed quite a bit. As such, we are proceeding to assign this issue to the content author to review further and take the right course of action.

aaronhudon commented 4 years ago

Creating an eventgrid subscription to a deployment slot doesn't work in the portal!

MatchingRadar commented 4 years ago

Hi - I agree this is an issue - however I would like to extend it to say that there are different issues between the azure cli, the azure portal and the azure powershell sdk. In the Azure portal i can successfully subscribe my even topic to my azure function - this then shows in the portal as an AzureFunction endpoint - when i use powershell i can successfully subscribe to my event grid using New-AzEventGridSubscription but can not create an AzureFunction endpoint; only one that will show up as a webhook. Then finally with the azure cli despite following the above examples to get the various different keys etc, I am still unable to get the function to respond with the validation result required for it to think it was successful and create the subscription. Both powershell and azure cli seem to be missing the ability to create the AureFunction endpoint unless this is automatically assigned somehow. At the minute the only way i can successfully bind an event topic to my azure function is in the portal, which is not so great for automatic deployment from something like AzureDevOps.

ebrucucen commented 4 years ago

Hi, I had the same issue. I think az cli version could be the issue (I am using 2.3.1) and it does not recognise the "resource" subcommand. Here is how I managed to create via az. Key is the _master for eventgrid_extension System Key, and eventSubscriptionName is any name you want to give for the eventSubscription:

systemKey=$(curl "http://${functionAppName}.azurewebsites.net/admin/host/systemkeys/eventgrid_extension?code=${masterKey}" | jq '.value' -r)
endpoint="https://${funcAppName}.azurewebsites.net/runtime/webhooks/eventgrid?functionName=${funcName}&code="${systemKey}"
sourceResourceId="/subscriptions/${subscriptionID}/resourceGroups/${resourceGroupName}/providers/Microsoft.EventGrid/topics/${topicName}"
az eventgrid event-subscription create --endpoint $endPoint \
    --source-resource-id $sourceResourceId \
    --name $eventSubscriptionName