Home > DevOps > Azure DevOps | Power Platform Build Tools | WhoAmI | Capture Environment ID

Azure DevOps | Power Platform Build Tools | WhoAmI | Capture Environment ID

Azure DevOps along with Power Platform Build Tools results a healthy Power Platform ALM.

In this article, I will explain how to use Power Platform WhoAmI task and capture the ‘Environment ID’.

What is PowerPlatformWhoAmi task:

  • Verifies a Power Platform environment service connection by connecting and making a WhoAmI request.
  • This task can be useful to include early in the pipeline, to verify connectivity before processing begins.

YAML snippet of WhoAmi:

Following is the YAML snippet which we would need to include in pipeline.

- task: microsoft-IsvExpTools.PowerPlatform-BuildTools.whoami.PowerPlatformWhoAmi@0
  displayName: 'Power Platform WhoAmI'

  inputs: 
#   Service Principal/client secret (supports MFA)
    authenticationType: PowerPlatformSPN
    PowerPlatformSPN: '{My service connection}'
  • This is how the pipeline YAML looks like.
    • Please note that we must have “PowerPlatformToolInstaller” task before executing “PowerPlatformWhoAmi” task.

Output of PowerPlatformWhoAmi:

  • When you run the pipeline, you would get following outcome for ‘PowerPlatformWhoAmi’.
  • In the output, there is this useful ‘Organization Information’ (Highlighted above) like Org ID, Unique Name, Environment ID etc…

Capture the ‘Environment ID’:

  • As we noticed, in the output of PowerPlatformWhoAmi, we could see useful ‘Organization Information’.
  • PowerPlatformWhoAmi output will be persisted in “BuildTools” Environment Variables.
  • To capture the ‘Environment ID’ use this convention $(BuildTools.EnvironmentId).
  • Use ‘echo’ to test the EnvironmentId as shown below.
  • Once you run the pipeline, you should see the EnvironmentId. As $(BuildTools.EnvironmentId) is an Environment variable, you can use in subsequent pipelines as well.

🙂

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: