Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snippets should encourage use of symbolicName.id where possible instead of using resourceId #3501

Closed
StephenWeatherford opened this issue Jul 7, 2021 · 1 comment · Fixed by #3745, #3780 or #3837

Comments

@StephenWeatherford
Copy link
Contributor

StephenWeatherford commented Jul 7, 2021

For instance, the 'res-nic' snippet output is this:

resource networkInterface 'Microsoft.Network/networkInterfaces@2020-11-01' = {
  name: 'name'
  location: resourceGroup().location
  properties: {
    ipConfigurations: [
      {
        name: 'name'
        properties: {
          privateIPAllocationMethod: 'Dynamic'
          subnet: {
            id: resourceId('Microsoft.Network/virtualNetworks/subnets', 'virtualNetwork', 'subnet')
          }
        }
      }
    ]
  }
}

RECOMMEND:

resource networkInterface 'Microsoft.Network/networkInterfaces@2020-11-01' = {
  name: 'name'
  location: resourceGroup().location
  properties: {
    ipConfigurations: [
      {
        name: 'name'
        properties: {
          privateIPAllocationMethod: 'Dynamic'
          subnet: {
            id: subnet.id
          }
        }
      }
    ]
  }
}

Note that this does show an error since subnet is. not defined:
image

Another possibilty would be to show the dependencies as explicit 'existing' resources, e.g.:

resource vnet 'Microsoft.Network/virtualNetworks@2021-02-01' existing = {
  name: 'Virtual network'
}

resource subnet 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' existing = {
  parent: vnet
  name: 'Subnet'
}

resource networkInterface 'Microsoft.Network/networkInterfaces@2020-11-01' = {
  name: 'name'
  location: resourceGroup().location
  properties: {
    ipConfigurations: [
      {
        name: 'name'
        properties: {
          privateIPAllocationMethod: 'Dynamic'
          subnet: {
            id: subnet::id
          }
        }
      }
    ]
  }
}
@bhsubra
Copy link
Contributor

bhsubra commented Jul 24, 2021

Pending:
res-loadbalancer-external.bicep
res-loadbalancer-internal.bicep
res-log-analytics-solution.bicep

@StephenWeatherford StephenWeatherford changed the title Snippets should encourage use of symbolicName.id instead of using resourceId Snippets should encourage use of symbolicName.id where possible instead of using resourceId Jul 29, 2021
@bhsubra bhsubra reopened this Jul 30, 2021
@ghost ghost locked as resolved and limited conversation to collaborators May 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.