Open vhvb1989 opened 4 months ago
@vhvb1989 Huh, I'm confused, as I had to write code today in another project to explicitly disable the preprovision/postprovision hooks as they were not able to run in CI. Not sure if I had a different azd version or something? https://github.com/Azure-Samples/openai-chat-app-entra-auth-local/actions/runs/9132623645/job/25114347007
@pamelafox , in your case, your pipeline has a call to azd env set FOOO something
here: https://github.com/Azure-Samples/openai-chat-app-entra-auth-local/blob/main/.github/workflows/azure-dev.yaml#L80
That's is creating the azd env.. then when azd provision
runs, hooks are correctly invoked.
I just had another developer run into this on a new repo, who was very confused as to why the hooks weren't running and wasn't sure how to debug. They're trying your workaround now.
Consider the next azd project sample:
If we run
azd provision --no-prompt
and:.azure
folder: The hook is not triggered b/c there is no environment.See: https://github.com/Azure-Samples/azure-search-openai-demo/issues/1603
This is an issue when azd runs in CI, because the
.azure
folder is not in the repo. Instead, azd usesAZURE_ENV_NAME
to create the .azure folder with a new env using the name from that env var. However, the hooks registration happens before the environment is created, so the hooks are ignored.Workaround:
For CI, add one step to create the environment before calling azd provision, like:
The
--no-prompt
flag is not supported forazd env new
, so, we need to use the env var from github as the argument for creating the environment.Reproduce locally
azd init
with minimal template)preprovision
hook like the one mentioned above.azure
(leaving the state as it would be in CI)azd provision --no-prompt
and observe how hook is ignored and the .azure folder is created. If you run it again, the hook is now honored (b/c the env is there)