6

I'm deploying an App Service Plan using an ARM Template. The template worked yesterday. After the deployment, I deleted the resource. Then, today, I'm trying to redeploy the same resource with the same ARM template and I'm getting the following error:

{
  "code": "InvalidTemplateDeployment",
  "details": [
    {
      "message": "Object reference not set to an instance of an object."
    }
  ],
  "message": "The template deployment 'Microsoft.Template-20220809104848' is not valid according to the validation procedure. The tracking id is 'ae29e10d-8e67-4131-988c-236d65af0f89'. See inner errors for details."
}

I've searched a lot trying to understand what this message "Object reference not set to an instance of an object" means, but I couldn't find anything. I tryed to download the same template from the deployment log, the one that worked yesterday, and use it again, but I still got this error.

This is the template I'm using:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.9.1.41621",
      "templateHash": "8638675738336979076"
    }
  },
  "resources": [
    {
      "type": "Microsoft.Web/serverfarms",
      "apiVersion": "2020-12-01",
      "name": "dfp-testing",
      "location": "centralus",
      "sku": {
        "name": "F1",
        "capacity": 1
      }
    }
  ]
}

So, I'm lost. I really don't know what is happening here.

Thanks for your help.

  • Glad to see someone else has had this issue today as I spent the day gutting my Bicep template to debug as I got the same error and narrowed it down to the ServerFarm resource. Anyone know which Github repo to submit an issue like this to? – Padraic Aug 09 '22 at 19:46
  • Try use EastUS2 which is the paired region of CentralUS – Padraic Aug 09 '22 at 19:53
  • I've tried the same template in another region and it worked. So, I'm believe that the problem should really be something with Azure. – Daniel Prado Aug 10 '22 at 12:12
  • @Padraic i'd like to know where I can report this, too. I searched within the portal where I could report this error, but I couldn't find it. – Daniel Prado Aug 10 '22 at 12:16
  • @DanielPrado would be helpful if u can accept Padraic’s answer. – n1989 Aug 30 '22 at 19:18
  • I accepted it. Thanks, @n1989 – Daniel Prado Sep 13 '22 at 18:51

3 Answers3

9

Add an empty properties field to your server farms resource and it should fix things. Looks like they added it as a required field recently. Hope this helps!

{
      "type": "Microsoft.Web/serverfarms",
      "apiVersion": "2020-12-01",
      "name": "dfp-testing",
      "location": "centralus",
      "sku": {
        "name": "F1",
        "capacity": 1
      },
      "properties": {}
    }
Padraic
  • 667
  • 3
  • 10
  • 1
    I can confirm the same exact thing happens/works with **Bicep**! – iRubens Aug 24 '22 at 09:28
  • 2
    Unreal. Surely if you're introducing a breaking change like this, you update the bicep validation so that you get a friendly error message, rather than throwing a null reference exception at run time! Thank you very much, you saved me a lot of hassle. – DaveF Aug 24 '22 at 20:37
  • Isn't the whole point in versioning the API that there will be no breaking changes? And @Padraic where did you see that the properties property is required? From the documentation it looks like it is not required in any of the serverfarm versions I looked at. Specifically the one referenced above: https://learn.microsoft.com/en-us/azure/templates/microsoft.web/2020-12-01/serverfarms?pivots=deployment-language-bicep It does seem to be the problem however, since adding an empty "properties" helped.. – TenaciousG Aug 26 '22 at 11:56
  • Just to register here, this is the solution. It's true, @TenanciousG, no where on the docs this field is shown as mandatory. – Daniel Prado Sep 13 '22 at 18:50
1

I can't tell you why it happens. But it seems a problem with the location. Deploying the template in West Europe for example works. Maybe there is a temporary issue in this region

0

It seems that the ARM-Template you're providing is invalid in term of including all the required elements/attributes. Please refer to Create App Service app using an ARM template and make sure you have a complete template. For example: properties could be required.