MicrosoftDocs / azure-docs

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

Unable to follow this documention #69007

Open Gamecock opened 3 years ago

Gamecock commented 3 years ago

The first thing wrong is that page says to get the system key: https://{functionappname}.azurewebsites.net/runtime/webhooks/eventgrid?functionName={functionname}&code={systemkey}

That URL returns a 404. An event grid trigger has to be published to the function app before that command will work. https://github.com/Azure/azure-functions-eventgrid-extension/issues/70

The next thing wrong is the event subscription:

az eventgrid resource event-subscription create -g myResourceGroup \ --provider-namespace Microsoft.Storage --resource-type storageAccounts \ --resource-name myblobstorage12345 --name myFuncSub \ --included-event-types Microsoft.Storage.BlobCreated \ --subject-begins-with /blobServices/default/containers/images/blobs/ \ --endpoint https://mystoragetriggeredfunction.azurewebsites.net/runtime/webhooks/eventgrid?functionName=imageresizefunc&code=<key>

az eventgrid resource is not in the az cli, I went down a rathole before I gave up.

This helped, it provided enough hints on how to generate an event when a blob is created. https://docs.microsoft.com/en-us/azure/event-grid/blob-event-quickstart-portal?toc=/azure/storage/blobs/toc.json


Document Details

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

SnehaAgrawal-MSFT commented 3 years ago

@Gamecock Thanks for the feedback! We are taking a look into this and will get back to you soon.

PramodValavala-MSFT commented 3 years ago

@Gamecock Sorry for the trouble with the docs.

The endpoints are registered once the event grid extension is registered with the Functions Runtime when such a function is added. Hence the behavior of the 404 is expected.

As for the Azure CLI command, the command should just be az eventgrid event-subscription. We will work up a PR for this, which once merged should reflect in a couple of hours.

PramodValavala-MSFT commented 3 years ago

@Gamecock On further review, since the CLI now supports Azure Function as an endpoint type, you don't have to build the endpoint URLs anymore. A direct command like this will work

az eventgrid event-subscription create --name es3 \
    --source-resource-id "/subscriptions/{SubID}/resourceGroups/{RG}/providers/Microsoft.Storage/storageaccounts/s1" \
    --endpoint-type azurefunction \
    --endpoint "/subscriptions/{SubID}/resourceGroups/{RG}/providers/Microsoft.Web/sites/{functionappname}/functions/{functionname}"

Hope that helps. We are assigning this issue to the content author for further review and to update the doc accordingly.