Azure / bicep-registry-modules

Bicep registry modules
MIT License
465 stars 308 forks source link

[AVM Question/Feedback]: Bicep module vs Json parameter file #3091

Closed abhiramani-git closed 4 days ago

abhiramani-git commented 3 weeks ago

Check for previous/existing GitHub issues

Description

Hi I am seeing all examples have Bicep module vs Json parameter file . i want to use json parameter files but what exact bicep file do i create to pass my json parameter. because current bicep file is hardcoded to all values anyways. i am trying to find quick way to run one example copy paste bicep,copy paste json parameter file and run command

am i missing something?

for example i have taken this json from from Virtual machine example. can you please help me what exact bicep code i write to pass this json parameter file for virtual machine?

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    // Required parameters
    "adminUsername": {
      "value": "localAdminUser"
    },
    "imageReference": {
      "value": {
        "offer": "0001-com-ubuntu-server-jammy",
        "publisher": "Canonical",
        "sku": "22_04-lts-gen2",
        "version": "latest"
      }
    },
    "name": {
      "value": "cvmlinmin"
    },
    "nicConfigurations": {
      "value": [
        {
          "ipConfigurations": [
            {
              "name": "ipconfig01",
              "pipConfiguration": {
                "name": "pip-01"
              },
              "subnetResourceId": "<subnetResourceId>"
            }
          ],
          "nicSuffix": "-nic-01"
        }
      ]
    },
    "osDisk": {
      "value": {
        "caching": "ReadWrite",
        "diskSizeGB": 128,
        "managedDisk": {
          "storageAccountType": "Premium_LRS"
        }
      }
    },
    "osType": {
      "value": "Linux"
    },
    "vmSize": {
      "value": "Standard_DS2_v2"
    },
    "zone": {
      "value": 0
    },
    // Non-required parameters
    "disablePasswordAuthentication": {
      "value": true
    },
    "location": {
      "value": "<location>"
    },
    "publicKeys": {
      "value": [
        {
          "keyData": "<keyData>",
          "path": "/home/localAdminUser/.ssh/authorized_keys"
        }
      ]
    }
  }
}
microsoft-github-policy-service[bot] commented 3 weeks ago

[!IMPORTANT] The "Needs: Triage :mag:" label must be removed once the triage process is complete!

[!TIP] For additional guidance on how to triage this issue/PR, see the BRM Issue Triage documentation.

microsoft-github-policy-service[bot] commented 2 weeks ago

[!WARNING] Tagging the AVM Core Team (@Azure/avm-core-team-technical-bicep) due to a module owner or contributor having not responded to this issue within 3 business days. The AVM Core Team will attempt to contact the module owners/contributors directly.

[!TIP]

  • To prevent further actions to take effect, the "Status: Response Overdue 🚩" label must be removed, once this issue has been responded to.
  • To avoid this rule being (re)triggered, the ""Needs: Triage :mag:" label must be removed as part of the triage process (when the issue is first responded to)!
AlexanderSehr commented 2 weeks ago

Hey @abhiramani-git, when using a JSON parameter file, you'd just store that file somewhere and then pass it into the deploying cmdlet alongside the reference to the template you want to deploy. Let's take your VM example above. To use it

  1. Store it as a JSON file (e.g., vm.parameters.json)
  2. Invoke New-AzResourceGroupDeployment -TemplateParameterFile '<pathToFile>/vm.parameters.json' -TemplateFile '<pathToVMModuleFolder>/main.bicep' -ResourceGroupName 'my-rg' Alternatively, you can also reference the main.json file. The cmdlet should be fine with both. Also, there may be a way to do the same using Az CLI commands, but I'd not know the command from the top of my head.

One other note regarding the JSON parameter file example. While it is directly rendered from the actual deployments we're performing in the CI to validate the module, they cannot be used 1:1 (but almost). Every time you see something like <heyThere> you have to add a value (e..g, "subnetResourceId": "<subnetResourceId>") and make sure that reference also exists :) In case of the VM module for example, you have to create the VNET before deploying the VM module into it.

I hope the above helps 💪

PS: In the future we'll also add examples for Bicep parameter files. But it's not the highest item on the list of priorities and will hence take some time.

microsoft-github-policy-service[bot] commented 1 week ago

[!WARNING] Tagging the AVM Core Team (@Azure/avm-core-team-technical-bicep) due to a module owner or contributor having not responded to this issue within 3 business days. The AVM Core Team will attempt to contact the module owners/contributors directly.

[!TIP]

  • To prevent further actions to take effect, the "Status: Response Overdue 🚩" label must be removed, once this issue has been responded to.
  • To avoid this rule being (re)triggered, the ""Needs: Triage :mag:" label must be removed as part of the triage process (when the issue is first responded to)!
microsoft-github-policy-service[bot] commented 1 week ago

[!CAUTION] This issue requires the AVM Core Team's (@Azure/avm-core-team-technical-bicep) immediate attention as it hasn't been responded to within 6 business days.

[!TIP]

  • To avoid this rule being (re)triggered, the "Needs: Triage :mag:" and "Status: Response Overdue :triangular_flag_on_post:" labels must be removed when the issue is first responded to!
  • Remove the "Needs: Immediate Attention :bangbang:" label once the issue has been responded to.
microsoft-github-policy-service[bot] commented 1 week ago

[!IMPORTANT] @abhiramani-git, this issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

[!TIP] To prevent further actions to take effect, one of the following conditions must be met:

  • The author must respond in a comment within 3 days of this comment.
  • The "Status: No Recent Activity :zzz:" label must be removed.
  • If applicable, the "Status: Long Term :hourglass_flowing_sand:" or the "Needs: Module Owner :mega:" label must be added.
microsoft-github-policy-service[bot] commented 4 days ago

[!WARNING] @abhiramani-git, this issue will now be closed, as it has been marked as requiring author feedback but has not had any activity for 7 days.

[!TIP] In case this issue needs to be reopened (e.g., the author responds after the issue was closed), the "Status: No Recent Activity :zzz:" label must be removed.