{"id":1184,"date":"2025-08-14T16:58:01","date_gmt":"2025-08-14T15:58:01","guid":{"rendered":"https:\/\/wp.bizoir.dk\/?p=1184"},"modified":"2025-08-23T10:01:44","modified_gmt":"2025-08-23T09:01:44","slug":"azure-bicep-deployment-nodescript-error","status":"publish","type":"post","link":"https:\/\/wp.bizoir.dk\/?p=1184","title":{"rendered":"Azure Bicep deployment &#8211; non-descript error"},"content":{"rendered":"<p>Azure deployment can be hard.<\/p>\n<p>To deploy and maintain azure resources, we are using bicep templates (a main template, invoking child modules to create individual resources). In addition we have environment-parameter-files, to encapsulate the differences between each environment.<\/p>\n<p>Today, I had to add some Function App Alerts via the bicep-template. Basically the only part in this task, was to create a new module, that could create the Alerts for an array of Function Apps.<\/p>\n<p>Feeling confident, I made the change, pushed it to the Azure Devops repository and invoked the Devops pipeline.<\/p>\n<p>Sadly it failed with this very non-descriptive failure<\/p>\n<p><code>ERROR: InvalidTemplate - Deployment template validation failed: 'The<br \/>\ntemplate resource 'xxKeyVault' at line '1' and column '9939' is<br \/>\nnot valid: The template function 'reference' is not expected at this<br \/>\nlocation. Please see https:\/\/aka.ms\/arm-functions for usage details..<br \/>\nPlease see https:\/\/aka.ms\/arm-functions for usage details.'.<\/code><\/p>\n<p>I had no idea about the reason &#8211; since i had changed nothing wrt. keyvaults and added no references.<\/p>\n<p><code>az bicep lint<\/code> showed no issues.<\/p>\n<p>The ARM-template file that Devops was trying to deploy, was not available (we use MS  agents)<\/p>\n<p>Trying local deployment:<\/p>\n<p><code>az deployment group what-if --name Test --resource-group rg-test-dev<br \/>\n--template-file modules\\main.bicep --parameters params\\dev.json<br \/>\n--subscription \"Test - DEV\" --mode Incremental<\/code><\/p>\n<p>showed the same error &#8211; but gave no indications to the cause.<\/p>\n<p>Doing a bicep build (<code>az bicep build --file modules\\main.bicep<\/code>) produced a template-file, but it was clearly not identical to the one that Devops pipeline did<\/p>\n<p>After hours of debugging, the error turned out to be simple:<br \/>\n<code>module functionAppAlerts 'functionAppAlerts.bicep' = {<br \/>\n   <strong>name: 'functionAppAlerts'<\/strong><br \/>\n   params: {<br \/>\n     actionGroupId: actionGroups.outputs.actionGroupsId<br \/>\n     timerTriggeredFunctionApps: functionAppNames_timerTriggered<br \/>\n     location: location<br \/>\n     tags: tags<br \/>\n   }<br \/>\n}<\/code><\/p>\n<p>I had not given the module a name.<\/p>\n<p>Currently, I have no idea, how this oversight could lead to the error above.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Azure deployment can be hard. To deploy and maintain azure resources, we are using bicep templates (a main template, invoking child modules to create individual resources). In addition we have environment-parameter-files, to encapsulate the differences between each environment. Today, I had to add some Function App Alerts via the bicep-template. Basically the only part in &hellip; <a href=\"https:\/\/wp.bizoir.dk\/?p=1184\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Azure Bicep deployment &#8211; non-descript error&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[30],"class_list":["post-1184","post","type-post","status-publish","format-standard","hentry","category-guides","tag-azure"],"_links":{"self":[{"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/posts\/1184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1184"}],"version-history":[{"count":5,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/posts\/1184\/revisions"}],"predecessor-version":[{"id":1196,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/posts\/1184\/revisions\/1196"}],"wp:attachment":[{"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}