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

Symbolic name template codegen dependsOn statements not generated correctly for "existing" resources #10343

Closed
anthony-c-martin opened this issue Apr 7, 2023 · 1 comment · Fixed by #11478
Assignees
Labels
bug Something isn't working
Milestone

Comments

@anthony-c-martin
Copy link
Member

Repro:

resource foo1 'Microsoft.Storage/storageAccounts@2022-09-01' = {
  name: 'foo'
}

resource foo2 'Microsoft.Authorization/roleAssignments@2022-04-01' existing = {
  scope: foo1
  name: 'blah'
}

resource foo3 'Microsoft.Storage/storageAccounts@2022-09-01' = {
  name: 'foo3'
  properties: {
    accessTier: foo2.properties.updatedBy
  }
}

Generates:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "languageVersion": "1.10-experimental",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_EXPERIMENTAL_WARNING": "Symbolic name support in ARM is experimental, and should be enabled for testing purposes only. Do not enable this setting for any production usage, or you may be unexpectedly broken at any time!",
    "_generator": {
      "name": "bicep",
      "version": "0.16.1.55165",
      "templateHash": "12852337686590580900"
    }
  },
  "resources": {
    "foo1": {
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2022-09-01",
      "name": "foo"
    },
    "foo2": {
      "existing": true,
      "type": "Microsoft.Authorization/roleAssignments",
      "apiVersion": "2022-04-01",
      "scope": "[format('Microsoft.Storage/storageAccounts/{0}', 'foo')]",
      "name": "blah",
      "dependsOn": [
        "foo1"
      ]
    },
    "foo3": {
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2022-09-01",
      "name": "foo3",
      "properties": {
        "accessTier": "[reference('foo2').updatedBy]"
      },
      "dependsOn": [
        "foo1"
      ]
    }
  }
}

My expectation is for foo3's dependsOn to reference foo2 rather than foo1.

@ghost ghost added the Needs: Triage 🔍 label Apr 7, 2023
@jeskew
Copy link
Contributor

jeskew commented Apr 7, 2023

Wouldn't the [reference('foo2').updatedBy] expression create an implicit dependency? I would think the dependsOn property in foo3 is redundant since a by-name reference to foo2 is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants