title: Azure Bicep RG Deployment - Object reference not set to an instance of an object
body: <p>I have a simple bicep template to deploy an app service pland and a website to a resource group.</p>
  <p>This used to work ok but now I get the following error:</p>
  <blockquote>
  <p>The template deployment
  'RB01' is not valid according to the validation procedure
  Object reference not set to an instance of an object</p>
  </blockquote>
  <p>The content of the bicep file is as follows:</p>
  <pre><code>targetScope = 'resourceGroup'
  param env string = 'dev'
  param formattedInstanceNum string = '001'
  param rgLocation string = resourceGroup().location
  
  //App Svc Plan
  resource appPlan 'Microsoft.Web/serverfarms@2021-01-01' = {
    name: 'svcplan-projname-${env}-${formattedInstanceNum}'
    location: rgLocation
    kind: 'linux'
    sku: {
      name: 'B1'
      tier: 'Basic'
    }
  }
  
  //Web Api App Svc
  resource webApi 'Microsoft.Web/sites@2021-03-01' = {
    name: 'appsvc-projname-webapi-${env}-${formattedInstanceNum}'
    location: rgLocation
    properties: {
      serverFarmId: appPlan.id
    }
  }
  </code></pre>
  <p>I run the bicep from a VSCode terminal window with the following cmdlet:</p>
  <pre><code>New-AzResourceGroupDeployment -Name 'RB01' -ResourceGroupName 'rg-projname-dev-001' -TemplateFile 'main.bicep' -env 'dev'  
  </code></pre>
  <p>I've tried running this with the -debug param but that didn't help - gave the same error message without being more specific as to what was causing the null ref exception.</p>
  <p>To check I had latest version of bicep I ran &quot;az bicep upgrade&quot;, this gave the message &quot;Installing Bicep CLI v0.9.1...&quot;. After a few seconds, it gave the message &quot;Successfully installed Bicep...&quot;. However, I than ran and it presented &quot;Bicep CLI version 0.4.613&quot;.</p>
  <p>Anyone see what's wrong with my template?</p>