Search code examples
bashazureazure-cli

How can I use AzD/Azure Developer CLI environment values in my script?


AzD shows me values like these after my deployment:

$ azd env get-values
...
AZURE_CONTAINER_REGISTRY_ENDPOINT="contreg.azurecr.io"
AZURE_CONTAINER_REGISTRY_NAME="contreg"
SERVICEBUS_ENDPOINT="https://sb.servicebus.windows.net:443/"
SERVICE_TESTDATA_IMAGE_NAME="contreg.azurecr.io/test-data/test-data:azdev-deploy-1665835078"
TESTDATA_URI="https://test-data.nicedune-eccf12fx.westeurope.azurecontainerapps.io"

How can I get e.g. TESTDATA_URI in a bash script to work with the endpoint?


Solution

  • Output from azd env get-values can be piped into source statement to have these values available:

    #!/bin/bash
    
    source <(azd env get-values)
    
    curl -X POST "$TESTDATA_URI/api/Generate"