Skip to content

Update Deploy-FinOpsHub.ps1 - #1243

Merged
Michael Flanakin (flanakin) merged 1 commit into
microsoft:devfrom
JayAreP:dev
Jan 26, 2025
Merged

Michael Flanakin (flanakin) merged 1 commit into
microsoft:devfrom
JayAreP:dev

Conversation

@JayAreP

@JayAreP J.R. Phillips (JayAreP) commented Jan 14, 2025

Copy link
Copy Markdown
Contributor

when expressing a [switch] parameter as a boolean in a hashtable you need to express the .IsPresent property.

enableInfrastructureEncryption was being parsed as an object rather than a boolean causing the error:

Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The provided value for the template parameter 'enableInfrastructureEncryption' is not valid. Expected a value of type 'Boolean', but received a value of type 'Object'.

🛠️ Description

Fixes #

📷 Screenshots

📋 Checklist

🔬 How did you test this change?

  • 🤏 Lint tests
  • 🤞 PS -WhatIf / az validate
  • 👍 Manually deployed + verified
  • 💪 Unit tests
  • 🙌 Integration tests

🙋‍♀️ Do any of the following that apply?

  • 🚨 This is a breaking change.
  • 🤏 The change is less than 20 lines of code.

📑 Did you update docs/changelog.md?

  • ✅ Updated changelog (required for dev PRs)
  • ➡️ Will add log in a future PR (feature branch PRs only)
  • ❎ Log not needed (small/internal change)

📖 Did you update documentation?

  • ✅ Public docs in docs (required for dev)
  • ✅ Internal dev docs in src (required for dev)
  • ➡️ Will add docs in a future PR (feature branch PRs only)
  • ❎ Docs not needed (small/internal change)

when expressing a [switch] as a boolean in a hashtable you need to express the .IsPresent property.

enableInfrastructureEncryption was being parsed as an object rather than a boolean causing the error:

Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The provided value for the template parameter 'enableInfrastructureEncryption' is not valid. Expected a value of type 'Boolean', but received a value of type 'Object'.
@JayAreP

J.R. Phillips (JayAreP) commented Jan 14, 2025

Copy link
Copy Markdown
Contributor Author

Was getting errors when attempting to Deploy-FinOpsHub. Was in Azure CloudShell PS session, but the switch behavior is consistent.

Example:

function switchtest {
    param(
        [switch] $switchtest
    )

    $hashtable = @{}
    $hashtable.Add("SwitchTest",$switchtest)

    return $hashtable
}

If you then run switchtest -switchtest | convertto-json
You'll see the resulting object rather than the expected boolean:

{
  "SwitchTest": {
    "IsPresent": true
  }
}

@flanakin

Copy link
Copy Markdown
Collaborator

allcontributors[bot] (@allcontributors) Please add JayAreP for code

@allcontributors

Copy link
Copy Markdown
Contributor

@flanakin
Michael Flanakin (flanakin) merged commit 1353127 into microsoft:dev Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Micro PR 🔬 Very small PR that should be especially easy for newcomers Needs: Review 👀 PR that is ready to be reviewed Tool: FinOps hubs Data pipeline solution Tool: PowerShell PowerShell scripts and automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants