https://pulumi.com logo
Title
p

plain-eye-9759

04/03/2020, 8:37 AM
Please help, I'm trying to create an Event Grid subscription to an Custom topic, using the Pulumi ARM template deployment. ARM template looks like this:
{
  name: "[concat(variables('topicName'), '/Microsoft.EventGrid/', variables('eventGridSubscriptionName'))]",
  type: "Microsoft.EventGrid/topics/providers/eventSubscriptions",
  location: "[variables('location')]",
  apiVersion: "2018-01-01",
  properties: {
      functionUrl: "[concat('https://', variables('functionAppName'),'.<http://azurewebsites.net/runtime/webhooks/eventgrid?functionName=|azurewebsites.net/runtime/webhooks/eventgrid?functionName=>', variables('functionName'),'&code=')]",
      destination: {
         endpointType: "WebHook",
         properties: {
            endpointUrl: "[concat(variables('functionUrl'), listKeys(resourceId('Microsoft.Web/sites/host/', variables('functionAppName'), 'default'),'2016-08-01').systemkeys.eventgrid_extension)]"
         }
      },
      filter: {
         includedEventTypes: [
             "All"
         ]
      }
   },
}
I'm getting this error
Encountered an error (ServiceUnavailable) from host runtime.
Looks like an Azure issue actually, but I don't know what the issue is. Also is there a way to do it directly with Pulumi? @tall-librarian-49374
t

tall-librarian-49374

04/03/2020, 8:39 AM
p

plain-eye-9759

04/03/2020, 8:46 AM
thanks, I was trying this earlier but not sure how to resolve the webhook endpoint, then I saw a codeblock you posted on Github
webhookEndpoint: {
   url: pulumi.all([this.functionApp.id, this.functionApp.defaultHostname]).apply(async ([id, hostname]) => {
   const creds = await AzureCliCredentials.create();
   const client = new AzureServiceClient(creds);
    const url = `<https://management.azure.com>${id}/host/default/listkeys?api-version=2018-02-01`;
    const response = await client.sendRequest({ method: 'POST', url });
    const systemKey = response.parsedBody.systemKeys.eventgrid_extension;
    return `https://${hostname}/runtime/webhooks/eventgrid?functionName=${name}&code=${systemKey}`;
        }),
    },
Whick package contains
AzureCliCredentials.create();
please?
ahh, I found
@azure/ms-rest-nodeauth
t

tall-librarian-49374

04/03/2020, 8:50 AM
I think you don’t have to do tis. If you have a
FunctionApp
you can call
functionApp.getHostKeys()
p

plain-eye-9759

04/03/2020, 8:51 AM
checking
Error: Failed to retrieve the host keys: {"Code":"BadRequest","Message":"Encountered an error (ServiceUnavailable) from host runtime.","Target":null,"Details":[{"Message":"Encountered an error (ServiceUnavailable) from host runtime."},{"Code":"BadRequest"},{"ErrorEntity":{"Code":"BadRequest","Message":"Encountered an error (ServiceUnavailable) from host runtime."}}],"Innererror":null}
Didn't work, I also tried
functionApp.getHostKeys().apply(keys => keys.systemKeys)
didn't work either. same error
t

tall-librarian-49374

04/03/2020, 9:13 AM
Sounds like a problem on Azure side?
p

plain-eye-9759

04/03/2020, 9:29 AM
looks like that