DEV Community

Dina Berry
Dina Berry

Posted on • Originally published at dfberry.github.io on

Add Azure Developer CLI deployment ID and UTC timestamp to Bicep files

If you frequently deploy to Azure with Azure Developer CLI, either through your local computer or through an automated pipeline, you need a quick and obvious way to track back from the Azure resource to the pipeline or deployment.

In order to mark the deployment resource itself, use the Azure Developer CLI's deployment().name and the Bicep utcNow() function to mark your deployments. The deployment().name is the name of your environment and a timestamp (expressed as a unix timestamp).

To use these in your bicep file, a sample snippet of code is provided:

param deploymentDateTimeUtc string = utcNow()
param deploymentName string = deployment().name
Enter fullscreen mode Exit fullscreen mode

You can use these variables in your Bicep to add as tags to your resources.

var tags = {
  'azd-env-name': environmentName
  'azd-deployment-id': deploymentName
  'azd-deployment-utc': deploymentDateTimeUtc
}
Enter fullscreen mode Exit fullscreen mode

You can also export the variables as an environment variable to use in post-processing activities.

output DEPLOYMENT_NAME string = deploymentName
output DEPLOYMENT_DATETIME_UTC string = deploymentDateTimeUtc
Enter fullscreen mode Exit fullscreen mode

If you are using Terraform instead of Bicep, with Azure Developer CLI, you still have access to the deployment name but the utcNow() is not available.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs