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

ARM to Bicep decompile error - The property "scope" expected a value of type "resource" but the provided value is of type "string" #10185

Open
mahalel opened this issue Mar 22, 2023 · 1 comment

Comments

@mahalel
Copy link

mahalel commented Mar 22, 2023

Bicep version

Bicep CLI version 0.15.31 (3ba6e06a8d)

Describe the bug

When attempting to decompile an ARM template for Microsoft.SecurityInsights/alertRules into a Bicep file, the conversion will present the following error:

/tmp/Fusion_tmp.bicep(7,10) : Error BCP036: The property "scope" expected a value of type "resource" but the provided value is of type "string".

To Reproduce
Steps to reproduce the behavior:

ARM file:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workspaceName": {
      "type": "string"
    },
    "enabled": {
      "type": "bool",
      "defaultValue": true
    }
  },
  "variables": {
    "ruleId": "f71aba3d-28fb-450b-b192-4e76a83015c8"
  },
  "resources": [
    {
      "type": "Microsoft.SecurityInsights/alertRules",
      "apiVersion": "2023-02-01-preview",
      "name": "[variables('ruleId')]",
      "scope": "[concat('Microsoft.OperationalInsights/workspaces/', parameters('workspaceName'))]",
      "kind": "Fusion",
      "properties": {
        "enabled": "[parameters('enabled')]",
        "alertRuleTemplateName": "f71aba3d-28fb-450b-b192-4e76a83015c8"
      }
    }
  ]
}

The expected Bicep output (valid):

param workspaceName string
param enabled bool = true

var ruleId = 'f71aba3d-28fb-450b-b192-4e76a83015c8'

resource Fusion 'Microsoft.SecurityInsights/alertRules@2022-10-01-preview' = {
  scope: workspace
  name: ruleId
  kind: 'Fusion'
  properties: {
    enabled: enabled
    alertRuleTemplateName: 'f71aba3d-28fb-450b-b192-4e76a83015c8'
  }
}
resource workspace 'Microsoft.OperationalInsights/workspaces@2022-10-01' existing = {
    name: workspaceName
}

Additional context

I have tried setting the scope in the ARM file to the exact name of the workspace as well, but I get the same error.

@brwilkinson
Copy link
Collaborator

brwilkinson commented Mar 29, 2023

I believe we have this covered over here:

This warning exists prior to the decompilation as well i.e. in the ARM template on the 'type'

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

4 participants