Azure / Azure/bicep

Deprecation of `/`-formatted child resource names

Open
#4,792 4 comments 1 reaction 0 assignees View on GitHub
devdiv intermediate language revisit story: linter rules
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

We eventually plan to deprecate this syntax entirely in favor of the safer parent property or nested resource syntax.

Related: #6921, #2841, #2446

We may want to implement #2245 & #2246 first to have less verbose options than having to declare `existing` resources.

I've repurposed this issue to track this plan. Here's the original issue text:
> Reported under https://github.com/Azure/bicep/issues/4789.
>
> Given the following Bicep file:
> ```bicep
> param networkResourcegroup string
> param subnetName string
> param sqlSAPW string
>
> var location = resourceGroup().location
>
> resource SAPVnetSubnet 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' existing = {
> name: subnetName
> scope: resourceGroup(networkResourcegroup)
> }
>
>
> resource SAPAzSQL 'Microsoft.Sql/managedInstances@2021-02-01-preview' = {
> name: 'sql-sap-prod-001'
> location: location
> sku: {
> name: 'GP_Gen5'
> tier: 'GeneralPurpose'
> capacity: 2
> }
> properties: {
> subnetId: SAPVnetSubnet.id
> storageSizeInGB: 32
> collation: 'SQL_Latin1_General_CP1_CI_AS'
> minimalTlsVersion: 'TLS_1_2'
> zoneRedundant: false
> administratorLogin: 'azsql'
> administratorLoginPassword: sqlSAPW
> vCores: 4
> licenseType: 'BasePrice'
> publicDataEndpointEnabled: false
> storageAccountType: 'LRS'
> }
> }
> ```
>
> It's very easy to miss the fact that the `SAPVnetSubnet` expects a `name` property to be fully-qualified (including both the vnet name, and the subnet name, separated by a `/`).
>
> To make things worse, because Bicep generates the following template expression, the error is quite cryptic:
> ```
> "[extensionResourceId(
> format('/subscriptions/{0}/resourceGroups/{1}',
> subscription().subscriptionId,
> parameters('networkResourcegroup')),
> 'Microsoft.Network/virtualNetworks/subnets',
> split(parameters('subnetName'), '/')[0],
> split(parameters('subnetName'), '/')[1]
> )]"
> ```
>
> The error returned (reference to an array index when there is no array index usage in the original Bicep file):
> ```
> The language expression property array index '1' is out of bounds.
> ```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.