Skip to content

scopes in settings.json is not properly populated #1880

@sandernaus

Description

@sandernaus

🐛 Problem

When deploying the FinOps toolkit to Azure and passing the scopesToMonitor parameter, the scopes are not properly populated in in the settings.json

👣 Repro steps

  1. Compile the bicep code az bicep build --file ./finops-hub-0.12/main.bicep
  2. Create the deployment az deployment group create --resource-group "finops-rg" --template-file $(Build.BuildId)/finops-hub-0.12/main.json --parameters scopesToMonitor="/sub/123-abc|/sub/456-def"
  3. Verify full deployment is completed
  4. Examine settings.json from the storage account
  5. Below is in the settings.json file
"scopes": {
  "scope": "/sub/123-abc"
}

🤔 Expected

Expected all subscriptions as part of the scopesToMonitor parameter to be in the settings.json

"scopes": [
    {
        "scope": "/sub/123-abc"
    },
    {
        "scope": "/sub/456-def"
    }
],

ℹ️ Additional context

The problem is in my view caused by the following to things in the Copy-FileToAzureBlob.ps1 script:

  • The object created for $newScopes is differently structure, compared to $json.scopes, resulting in not just merging them using the +
  • The validation for scopes is wrongly set, as now the length of the dictionary is checked (which is 1), and not the length of the string value for the actual scope key, causing all scopes to be discarded

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions