-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
azd env set
in a hook script doesn't have the variables available in future steps
#3973
Comments
@aaronpowell Can you provide some more information on the issue you are facing? During the execution of any hooks Conversely any calls to Some feedback regarding your linked script. I noticed you are running the following: # Use the `get-values` azd command to retrieve environment variables from the `.env` file
while IFS='=' read -r key value; do
value=$(echo "$value" | sed 's/^"//' | sed 's/"$//')
export "$key=$value"
done <<EOF
$(azd env get-values)
EOF This code is redundant since Question: Where are you looking to leverage the new variables you are creating? A common scenario would be to have your |
I was able to dive into this a little more. I have identified the root cause of the issue you are facing. In the @weikanglim / @ellismg - We should really remove the provision provider from initializing in the This line is the issue. |
I didn't realise it wasn't needed. It's possible that I just added it without testing, but I can remove it now.
The scripts are being used to create an App Registration in Entra, since there's no Bicep support (or at least, there wasn't at the time and I haven't been able to test the beta that was released), and then register the app with it for authentication. |
Yeah, we tend to use |
Just on this
I'm using PowerShell and I also have found I've had to use the output of I have lines such as this:
How would you recommend we do this @wbreza ? |
@bronthulke Assuming the following:
.azure/my-env/.env
With your hook script you can access this variable like the following: With shell/bash script: echo ${MY_CUSTOM_VAR} With Powershell Write-Output $env:MY_CUSTOM_VAR To easily test your hook scripts we also have a convience command, |
OK I'm not afraid to admit when I make a silly mistake... I kept trying to "check" the variable on a PS command line by simply doing $env:MY_CUSTOM_VAR I was forgetting to do an actual Write-Output $env:MY_CUSTOM_VAR It does indeed work. and just tidies up that code a little. That |
We had this azd env load in early scripts before we had |
Output from
azd version
Run
azd version
and copy and paste the output here:Describe the bug
If you use a hook, such as preprovision, to add environment variables to azd using
azd env set
, those variables aren't available until the azd session is restarted (meaning you can't useazd up
).We come across this in https://github.com/microsoft/azure-openai-service-proxy/ in which we have to create an Entra ID app registration and then want to push the client id/tenant id to services that azd will deploy.
Here is the preprovision hook definition and then here is the script.
The reason that we rely on this is there is no bicep support for deploying app registrations presently, so we use the Azure CLI to handle it.
Ideally, each step of the azd pipeline would load the
.env
file, even if it's being run through a group command likeazd up
.The text was updated successfully, but these errors were encountered: