Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
408 stars 198 forks source link

[Feature] Support provision w/o parameters file #2715

Open jongio opened 1 year ago

jongio commented 1 year ago

Right now main.parameters.json file is required.

It would be nice if it wasn't.

Scenario:

I want to tell someone to copy and paste main.bicep with as few steps as possible.

My main.parameters.json file is only the parameters that azd treats special.

  1. env name
  2. location
  3. principal id.

My thought is that we can have azd always supply those parameters at the command line instead of requiring them in a main.parameters.json file.

ellismg commented 1 year ago

My thought is that we can have azd always supply those parameters at the command line instead of requiring them in a main.parameters.json file.

I think having main.parameters.json default to something like this:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "environmentName": {
      "value": "${AZURE_ENV_NAME}"
    },
    "location": {
      "value": "${AZURE_LOCATION}"
    },
    "principalId": {
      "value": "${AZURE_PRINCIPAL_ID}"
    }
  }
}

When it is not present makes sense. I'm not sure about always passing these parameters, even when a main.parameters.json file is present. That feels like it is baking a lot of policy into the tool just based on parameter names than I am comfortable with.

Perhaps it also makes sense to default these values in the case where the file exists but does not define values for the environmentName, location and principalId values and the infrastructure requires them, so there's still a way for the user to override them.

We'd also probably want to do something similar for tfvar files for the Terraform case, as well.

Note that in the bicepparam case, we couldn't support this - the bicepparam file requires all of these parameters to be defined in the file when it is compiled, as @vhvb1989 discovered when he implemented the feature.

dkuwcreator commented 2 months ago

We'd also probably want to do something similar for tfvar files for the Terraform case, as well.

This would be great! I have been adding empty *.tfvars.json files to my tf folder as a workaround. Is this on the planning any time soon? I want to introduce azd as a local dev tool to work with our Terraform Modules in our company but adding empty files to make it work has been holding this back.

jongio commented 1 month ago

I'll take a look soon.