ARM Template listkeys() fails to find Azure Search

Viewed 1294

I'm creating an ARM Template to deploy both an Azure Search instance and a Function App that depends on the Azure Search instance. As part of that I'm trying to pre-populate the Function Apps app settings with the Search Service's API Key.

I'm doing this by adding the following into the value of one of the app settings of the FunctionAppSite:

[listKeys(variables('searchServiceId'), '2015-08-19').key1]

I get the searchServiceId in the variables sections

[resourceId('Microsoft.Search/searchServices', parameters('SearchServiceName'))]

The FunctionAppSite component lists dependencies on the AppServicePlan, StorageAccount and SearchService.

When I deploy the template the Search Service gets created then an error occurs because listkeys couldn't find the Search Service. This happens about .25s after the service is created.

I'm pretty sure I have the syntax around the listkeys correct and the problem is just the timing, no sure how I can slow it down though. I tried forcing the StorageAccount to depend on the SearchService in my template, hoping the dependency chain would slow things down enough, but the listkeys error happens after the Search Service is created, but before the StorageAccount is created.

The full template can be found here and there is a 'Deploy to Azure' button on the readme.md of that repo if you want to see it in action.

1 Answers
Related