Skip to content

Instantly share code, notes, and snippets.

@anthony-c-martin
Created February 8, 2021 16:46
Show Gist options
  • Save anthony-c-martin/221f33a65e50461d8e5f59068c983f89 to your computer and use it in GitHub Desktop.
Save anthony-c-martin/221f33a65e50461d8e5f59068c983f89 to your computer and use it in GitHub Desktop.
Bicep Parent/Scope syntax mockups

Syntax mockups

Existing Syntax

Root resource

resource myVm 'Microsoft.Compute/virtualMachines@2020-01-01' = {
  name: 'myVm'
  ...
}

Child resource

resource myChild 'Microsoft.Compute/virtualMachines/mockChildType@2020-01-01' = {
  name: 'myVm/myChild'
  ...
}

Extension resource

resource myVm 'Microsoft.Compute/virtualMachines@2020-01-01' existing = {
  name: 'myVm'
}

resource myAlerts 'Microsoft.Insights/metricAlerts@2020-01-01' = {
  scope: myVm
  name: 'myAlerts'
  ...
}

Child of extension resource

resource myVm 'Microsoft.Compute/virtualMachines@2020-01-01' existing = {
  name: 'myVm'
}

resource myChild 'Microsoft.Insights/metricAlerts/mockChildType@2020-01-01' = {
  scope: myVm
  name: 'myAlerts/myChild'
  ...
}

Extension of child resource

resource myChild 'Microsoft.Compute/virtualMachines/mockChildType@2020-01-01' existing = {
  name: 'myVm/myChild'
}

resource myAlerts 'Microsoft.Insights/metricAlerts@2020-01-01' = {
  scope: myChild
  name: 'myAlerts'
  ...
}

Proposed syntax ('parent' property)

Child resource

resource myVm 'Microsoft.Compute/virtualMachines@2020-01-01' existing = {
  name: 'myVm'
}

resource myChild 'Microsoft.Compute/virtualMachines/mockChildType@2020-01-01' = {
  parent: myVm
  name: 'myChild'
  ...
}

Child of extension resource

resource myVm 'Microsoft.Compute/virtualMachines@2020-01-01' existing = {
  name: 'myVm'
}

resource myAlerts 'Microsoft.Insights/metricAlerts@2020-01-01' existing = {
  scope: myVm
  name: 'myAlerts'
}

resource myChild 'Microsoft.Insights/metricAlerts/mockChildType@2020-01-01' = {
  parent: myAlerts
  name: 'myChild'
  ...
}

Extension of child resource

resource myVm 'Microsoft.Compute/virtualMachines@2020-01-01' existing = {
  name: 'myVm'
}

resource myChild 'Microsoft.Compute/virtualMachines/mockChildType@2020-01-01' existing = {
  name: 'myChild'
}

resource myAlerts 'Microsoft.Insights/metricAlerts@2020-01-01' = {
  scope: myChild
  name: 'myAlerts'
  ...
}

Discussed 'nested' syntax

Child resource

resource myVm 'Microsoft.Compute/virtualMachines@2020-01-01' existing = {
  name: 'myVm'

  resource myChild 'mockChildType@2020-01-01' = {
    name: 'myChild'
    ...
  }
}

Child of extension resource

resource myVm 'Microsoft.Compute/virtualMachines@2020-01-01' existing = {
  name: 'myVm'
}

resource myAlerts 'Microsoft.Insights/metricAlerts@2020-01-01' existing = {
  scope: myVm
  name: 'myAlerts'

  resource myChild 'mockChildType@2020-01-01' = {
    name: 'myChild'
    ...
  }
}

Extension of child resource

resource myVm 'Microsoft.Compute/virtualMachines@2020-01-01' existing = {
  name: 'myVm'

  resource myChild 'mockChildType@2020-01-01' existing = {
    name: 'myChild'
  }
}

resource myAlerts 'Microsoft.Insights/metricAlerts@2020-01-01' = {
  scope: myVm/myChild // TBD on this syntax to refer to the child of myVm
  name: 'myAlerts'
  ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment