Next Steps after azd init #
Table of Contents #
Next Steps #
Define environment variables for running services #
- Modify or add environment variables to configure the running application. Environment variables can be configured by updating the
settingsnode(s) for each service in main.parameters.json. - For services using a database, environment variables have been pre-configured under the
envnode in the following files to allow connection to the database. Modify the name of these variables as needed to match your application. - For services using Redis, environment variables will not show up under
envexplicitly, but are available as:REDIS_ENDPOINT,REDIS_HOST,REDIS_PASSWORD, andREDIS_PORT.
Provision infrastructure and deploy application code #
Run azd up to provision your infrastructure and deploy to Azure in one step (or run azd provision then azd deploy to accomplish the tasks separately). Visit the service endpoints listed to see your application up-and-running!
To troubleshoot any issues, see troubleshooting.
Configure CI/CD pipeline #
- Create a workflow pipeline file locally. The following starters are available:
- Run
azd pipeline config -e <environment name>to configure the deployment pipeline to connect securely to Azure. An environment name is specified here to configure the pipeline with a different environment for isolation purposes. Runazd env listandazd env setto reselect the default environment after this step.
What was added #
Infrastructure configuration #
To describe the infrastructure and application, azure.yaml along with Infrastructure as Code files using Bicep were added with the following directory structure:
- azure.yaml # azd project configuration
- infra/ # Infrastructure as Code (bicep) files
- main.bicep # main deployment module
- app/ # Application resource modules
- shared/ # Shared resource modules
- modules/ # Library modules
Each bicep file declares resources to be provisioned. The resources are provisioned when running azd up or azd provision.
- app/productivity_app.bicep - Azure Container Apps resources to host the 'productivity_app' service.
- shared/keyvault.bicep - Azure KeyVault to store secrets.
- shared/monitoring.bicep - Azure Log Analytics workspace and Application Insights to log and store instrumentation logs.
- shared/registry.bicep - Azure Container Registry to store docker images.
More information about Bicep language.
Build from source (no Dockerfile) #
Build with Buildpacks using Oryx #
If your project does not contain a Dockerfile, we will use Buildpacks using Oryx to create an image for the services in azure.yaml and get your containerized app onto Azure.
To produce and run the docker image locally:
- Run
azd packageto build the image. - Copy the Image Tag shown.
- Run
docker run -it <Image Tag>to run the image locally.
Exposed port #
Oryx will automatically set PORT to a default value of 80. Additionally, it will auto-configure supported web servers such as gunicorn and ASP .NET Core to listen to the target PORT. If your application already listens to the port specified by the PORT variable, the application will work out-of-the-box. Otherwise, you may need to perform one of the steps below:
- Update your application code or configuration to listen to the port specified by the
PORTvariable - (Alternatively) Search for
targetPortin a .bicep file under theinfra/appfolder, and update the variable to match the port used by the application.
Billing #
Visit the Cost Management + Billing page in Azure Portal to track current spend. For more information about how you're billed, and how you can monitor the costs incurred in your Azure subscriptions, visit billing overview.
Troubleshooting #
Q: I visited the service endpoint listed, and I'm seeing a blank or error page.
A: Your service may have failed to start or misconfigured. To investigate further:
- Click on the resource group link shown to visit Azure Portal.
- Navigate to the specific Azure Container App resource for the service.
- Select Monitoring -> Log stream under the navigation pane.
- Observe the log output to identify any errors.
- If there are no errors, ensure that the ingress target port matches the port that your service listens on:
- Under Settings -> Ingress, ensure the Target port matches the desired port.
- After modifying this setting, also update the
targetPortsetting in the .bicep file for the service underinfra/app.
- If logs are written to disk, examine the local logs or debug the application by using the Console to connect to a shell within the running container.
For additional information about setting up your azd project, visit our official docs.