Posts Tagged ‘PowerPlatformWhoAmi’

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'

#   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.