Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Unanswered

Azure DevOps Power Platform Build and Deployments and Azure Insights Instrumentation Key

(1) ShareShare
ReportReport
Posted on by 756 Super User 2024 Season 1

A Little Background

I build Power Apps for my company. We leverage Multiple DEV environments, UAT environments and production environments as part of our platform governance. What environments are used depends on what the app is and whom it is for.  We are also leveraging solutions to perform promotion from DEV->UAT->Production.  We have been doing that for about 9 months or so, but all manually. Ugh, what a PITA and so time consuming.

As part of our Power App development we are also leveraging Azure Insights, so we have the Instrumentation key stored in the App object. There lies our problem, the Instrumentation key value cannot use a variable or code to set it. It is basically hardcoded in the App object.  This presents a problem for us as we use different Azure Insights instances for each environment.

We are now in the process of introducing Azure DevOps into our deployment process. Eliminating the manual process we do now to move code from one environment to another.

So you are all caught up on what we have been up to...

DevOps Approach

We are building Pipelines to perform builds and promotion of our solutions.

Step One: Build Pipelines

Each Build Pipeline uses a Task group to create a new Build for a solution.  The Task group has the following steps:

  1. Export Solution as Managed
  2. Export Solution as Unmanaged
  3. Unpack Managed Solution
  4. Unpack Unmanaged Solution
  5. Publish Artifacts Managed Solution
  6. Publish Artifacts Managed Solution
  7. Check-in All Assets to Repository

So the goal here is to export a solution as both managed and unmanaged, unpack it, and store all the unpacked code in the source repository.

Our goal is to store the source of the exported ZIP files in source control, not the actual ZIP files. When we deploy a Solution to another environment we repack the solution from the repository and import that packed solution.

So that is step one... COMPLETED

Step Two-X: Work in Progress

What I would like to do from here is to pack the code back into solutions but first update the InstrumentationKey then import the solution into the appropriate environment.  I am looking for some advice on the best way to accomplish this.  We have instrumentation keys for DEV, UAT and Prod. So we would need to use the same source repository and update the key, pack a solution, then do it again for prod. (This would be so much easier if Microsoft allowed the use of an environment variable, or a variable period, to set the key.)  But short of that miracle, can anyone provide any advice on how best to accomplish what we need?

 

Thank in advance.

 

Steven

  • Dohsan Profile Picture
    28 on at
    Re: Azure DevOps Power Platform Build and Deployments and Azure Insights Instrumentation Key

    @sperry1625  Once you've unpacked the solution, use the powerapps CLI to unpack any apps in the solution (.msapp).

     

    The instrumentation key is handily stored in a file called AppInsightsKey.json and looks something like:

    {
     "InstrumentationKey": "00000000-0000-0000-0000-000000000000"
    }

    You can then update it in the pipeline before packing up the app and then the solution

    if (Test-Path -Path $AppPath\$AppName\AppInsightsKey.json -PathType Leaf) {
     Write-Host "AppInsightsKey.json found"
     ((Get-Content -Path $AppPath\$AppName\AppInsightsKey.json -Raw) -replace "$(InstrumentationKey-Dev)","$(InstrumentationKey-Pre)") | Set-Content -Path $AppPath\$AppName\AppInsightsKey.json 
     } 

     

     

  • Joeri Stroy Profile Picture
    49 on at
    Re: Azure DevOps Power Platform Build and Deployments and Azure Insights Instrumentation Key

    There are multiple tasks available in devops to find and replace text in an file.

     

    So when you deploy to an environment, before repacking the solution use a pipeline task to replace the instrumentation key with one you have in a devops variable and you are good to go. 

     

    One I frequentie use is replace tokens or magic chunks. 

     

    You should be able to achieve your requirements this way. 

     

     

  • sperry1625 Profile Picture
    756 Super User 2024 Season 1 on at
    Re: Azure DevOps Power Platform Build and Deployments and Azure Insights Instrumentation Key

    @TarunEY unfortunately we have not. I'm sure I could introduce a step in the Release pipeline that could update the key, I know exactly where it is stored, but I have not had the time, not the patience, to do it. So, for the moment I manually edit the application once deployed into the new environment and update the Instrumentation key.  Not the most ideal solution, but it works, for now.

     

    Regards,

     

    -S

  • TarunEY Profile Picture
    on at
    Re: Azure DevOps Power Platform Build and Deployments and Azure Insights Instrumentation Key

    @sperry1625  Any solution or workaround for the issue? We have the same requirement.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 81 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 53 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 48

Overall leaderboard