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
387 stars 179 forks source link

[Issue] Azdup --no-prompt not work for Azure-Samples/azure-search-openai-demo #4051

Open LianwMS opened 4 weeks ago

LianwMS commented 4 weeks ago

Repo: https://github.com/Azure-Samples/azure-search-openai-demo

Maybe need a good guideline here. The question is for above repo. When I run azd up --no-prompt it will fail as: ERROR: initializing provisioning manager: prompting for value: prompting for location: '' is not an allowed choice. allowed choices: 1. (Europe) West Europe (westeurope), 2. (US) East US (eastus), 3. (US) West US 2 (westus2)

Maybe since the parameter does not have default value and need people input during provision. (Not sure the root cause). In bicep https://github.com/Azure-Samples/azure-search-openai-demo/blob/a1fe90090e4e2e60cbd3fd73630f55c55ac2a3b9/infra/main.bicep#L81:

@description('Location for the OpenAI resource group')
@allowed([ 'canadaeast', 'eastus', 'eastus2', 'francecentral', 'switzerlandnorth', 'uksouth', 'japaneast', 'northcentralus', 'australiaeast', 'swedencentral' ])
@metadata({
  azd: {
    type: 'location'
  }
})
param openAiResourceGroupLocation string

@description('Location for the Document Intelligence resource group')
@allowed([ 'eastus', 'westus2', 'westeurope' ])
@metadata({
  azd: {
    type: 'location'
  }
})
param documentIntelligenceResourceGroupLocation string

If run azd up locally: image

Since the we want to run azd up in pipeline. So we add --no-prompt but it seems that not work here.

My question:

  1. Without changing the bicep, and solution to run real without manually input? means real --no-prompt? I know that maybe add environment variable in azd env maybe a solution. But assuming that we cannot know the which parameters needed before running azd up, since we will not read the bicep before it.
  2. If we can change the bicep, any suggestion? E.g. add some default value? but still let customer select during azd up?
weikanglim commented 3 weeks ago

The way --no-prompt works:

--no-prompt : Accepts the default value instead of prompting, or it fails if there is no default.

Indeed, since no default value was provided, the prompt failed.

Without changing the bicep, and solution to run real without manually input?

For configuring CI/CD, if you run azd pipeline config, the pipeline config command would prompt the user to provide the value. The value for these parameter are saved via AZD_INITIAL_ENVIRONMENT_CONFIG, so there isn't a need to set anything past that.