Open vhvb1989 opened 6 months ago
This enhancement will be useful to us since we are hoping to make the process of deploying samples easier for users using github actions. We use the azd commands as part of a github action to deploy an openAI sample, however we are currently blocked by the prompt regarding if files can be overwritten, since confirmation to an interactive command cannot be provided during CI/CD. It would be great if we could pass in an argument that would default it to overwrite files.
This is something azd could support, but I'm not sure about the full scenario yet.
@vaibbavis Were you expecting the files to be there and be overwritten? Like "overlaying" the template on top of some existing base layer?
@weikanglim, I can give a sample scenario.
I write code samples using AZD templates. For my code samples, I want the user to be able to use any one of these strategies:
Today, I can't provide instructions that support all three scenarios. If I provide these instructions:
azd init --template <name-of-template>
Then, the user is shown a dialog for two of those scenarios asking if they want to overwrite the local files. I had users give feedback that they think the sample is broken when this happens.
If I use these instructions:
azd init
It doesn't support the scenario if the user has an empty directory.
In an ideal world, I would like to give instructions to pull the sample that works in an empty directory or if you already have the sample (ex: GitHub Codespaces).
This command doesn't work because it responds "No":
azd init --template <name-of-template> --no-prompt
Ideally, a flag that responds yes like --confirm-prompt
or --yes-prompt
could solve the problem for me.
Here's an example of a documentation article where I have a code sample in AZD.
https://learn.microsoft.com/azure/cosmos-db/mongodb/quickstart-dotnet#setting-up
I'm getting feedback from users with both strategies I tried over the last few months:
Strategy | Type of user | Feedback |
---|---|---|
azd init --template cosmos-db-mongodb-dotnet-quickstart |
GitHub Codespace user | "Why does it ask me if I want to overwrite the files?" |
azd init |
Uses with an empty folder who don't want to or can't use a devcontainer | "It's prompting me for a template. What's the name of the template?" |
Ideally, I could have one command that works in all scenarios and overwrites when appropriate. I hope this is useful context.
@anfibiacreativa , since I think your model also needs this
@seesharprun That makes sense, thanks for the feedback.
I think we could indeed add --force
as Allows existing files to be overwritten without confirmation
.
In that world, the command could be given to initialize the template, regardless of environment setup (based on https://learn.microsoft.com/azure/cosmos-db/mongodb/quickstart-dotnet#setting-up):
Run
azd init
to initialize the projectazd init --template <name-of-template> --force
The things I may worry about in this world: did the user choose the right directory to run azd init
in? It will override any existing files if they did not choose correctly. A new template user might also form the impression that --force
seems to be the happy pathway.
I wonder if the instructions are calling out to start from dev container, then perhaps we can simply say:
- Open a terminal in the root directory of the project. Alternatively, if starting from an empty directory, run
azd init --template <name-of-template>
to fetch the template files from the GitHub repository.
A good suggestion that @vhvb1989 had is to perhaps pass the -e
flag to azd init
to specify a default environment, if we intend this document to be read by a user relatively early in the azure dev journey. A critique about this proposal is that the user gets prompted for environment initialization early, which is similar to the DX difficulty that @anfibiacreativa raised.
When running
azd init -t source/template
, if there are files in the current folder where azd is running, azd will first ask for a confirmation about using the current folder (as it might override files).The confirmation is a good way to prevent unwanted scenarios, but it becomes a blocker when users runs azd from CI/CD and they are intentionally running
azd init -t template
within a folder that contains other files.azd should allow some flag like
azd init -t template --force
for pre-approving the prompt for a non-empty folder