~/blog/connection-references
Published on

Simplifying Connection References in D365 Environments

Introduction

Hello, Dorks! Here’s another exciting tip that could free up some time for you to indulge in that Lord of the Rings marathon or perhaps finish that ongoing game of Dungeons & Dragons (our favourite kind of DORK action).

If you're reading this, chances are, you're a DORK with one of two needs. The first - you're here simply because you love what we do (and for that, we offer our heartfelt thanks), or secondly, you're racing against a deadline, hoping to nab this solution and emerge as the team's superhero. Imagine feeling like Grace Hopper, the legendary programmer after accomplishing this feat.

For those in a rush, click here to jump straight to the juice.

Problem

Let's address the Oliphaunt in the room: the common problem haunting us.

The challenge is deploying flows between environments. Each time you do this, the connection references disappear, forcing you to constantly create new ones and edit existing ones.

Rest easy, my fellow DORKS. Just as Samwise carried Frodo in the fellowship, we're here to carry you all the way to victory.

Sam's Promise

Requirements

  • D365 Environments (DEV and QA)
  • VsCode -> Installer
  • Azure DevOps tenant
  • Lord of the Rings extended edition (because you deserve a break) -> Buy it - Not sponsored

Disclaimer: You won't be able to do this with your personal account. You will need to have a work/school account.

What are thoooose? (quick help on the lango)

  • Service accounts -> is a special type of account used to interact with the system programmatically. It is typically a non-interactive user account that is designed to run background tasks, integrations, or automated processes;
  • DEV -> short for Development Environment - our home ❤️‍🔥;
  • QA -> short for Quality Assurance - a part of the software development lifecycle used specifically for testing the software to ensure it meets quality standards;
  • Connection References -> helps manage and utilize connections in your applications and flows. They were introduced to make it easier to manage and promote applications between different environments;
  • ADO -> Azure DevOps.

Setup

The setup should be second nature to you by now, but for posterity's sake, here's the equivalent of the Middle Earth travel guide:

Dynamics Envs

  • DEV and QA
  • Service accounts on each environment

Azure DevOps

Step 1 - Create a project

  • Navigate to your newly created Azure DevOps tenant and click on new project;
New Project
  • Fill in the modal with whatever fancy words you feeling to use;
Setup

Step 2 - Create a repository

  • Click on the 'Repos' sidebar menu and create a new one to store your dreams;
New Repository
  • You can complete this step from the ADO tenant or from the VsCode but you should end up with this Repository structure.
Repository Structure

Step 3 - VsCode

  • I would love to repeat my self on the VSCode and ADO setup but I don't need to anymore! We have been through all of that in our blog already. Visit this URL. **IT'S FREE!!**😎
  • This will be the PAC CLI command to use, on this tutorial, to get that deployment settings from the environment solution:
    pac solution create-settings --solution-zip «solution_zip_file_path» --settings-file «settings_file_name»
    

Step 4 - Create a pipeline

  • Time to get that pipeline going;
New Pipeline
  • We rolling with the empty job as a template because we know what we are doing! 🤥
Template option
  • TA DA! This is our frame to work on for our pipeline. How good is the smell of new pipelines? Am I right?
Pipeline Frame
  • Let's install Power Platform Build extension so we can have access to the right tasks
Marketplace Power Platform Build - 1
Marketplace Power Platform Build - 2
  • Perfect time to create the user serving as our service connection
Service Connection - 1
Service Connection - 2
Service Connection - 3
  • For quick tests (like this one) you can just use the generic version of the service connection but for real projects use the Power Platform connection type which points to an app registration. (You can find the details: Client Secret; App Id; Tenant Id - on the Azure tenant, where you create the app reg.)

Step 5 - Setup tasks

  • Just like Bob Ross on the good old days said: "It's hard to see things when you are too close." Let's paint!
Pipeline tasks - 1

For the Power Platform Export Solution Task:

  • 1st: Choose Authentication type;
  • 2nd: Service Connection;
  • 3rd: Solution Name (same as D365);
  • 4th: Export as Managed Solution.
Pipeline tasks - 2

For the Copy deploymentSettings Task:

  • 1st: Source Folder(this points to your repository);
  • 2nd: Contents;
  • 3rd: Target Folder.
Pipeline tasks - 3

And once again, like our beloved friend Bob Ross used to say: "...so, from all of us here, I'd like to wish you happy painting, and God bless, my friend..."

Pipeline tasks - 4

Step 6 - Create a release

  • Almost done! One more step to reach the Mount Doom!
New Release - 1
  • Really important stuff here - make sure you check the 'Use deployment settings file' is turned on and pointing to the right path of your artifact
New Release - 2

Solution

Now Gollum is the only thing left to pass throught... that and your greed for power.

  • Create a connection reference in your QA environment using your choosen account;
  • Note the 'Connection Reference Display Name' and the 'Connection Id' using Advanced Find;
Connection Reference
  • Create an independent solution for cloudflows and Connection References in DEV environment
Independent Solution
  • Update the deployment settings file in your repository;
{
  "ConnectionReferences": [
    {
      "LogicalName": "Microsoft Dataverse DorksCRMAutomations-0b5e9",
      "ConnectionId": "shared-commondataser-9a6d8a41-d56a-45f4-84ab-b4afc8db905d",
      "ConnectorId": "/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"
    }
  ]
}
  • Run the pipeline
  • Run the release
  • Pat yourself on the back. You did it!

It's Done!

Extras:

  • For a smoother operation and security concerns, use an App Registration as a Service Principal for Dataverse Connectors or a Service Account to create the Connection Reference.
  • The first time you do it make sure you turn on the flow on the Target environment. You will only need to do this only once.

Conclusion

This process provides a one-time setup for all the flows. You can reuse the connection reference, and if you add a new connector, simply update the .json file (deployment settings file). Even Sauron wouldn't stand a chance against our efficiency.

If solving problems like a DORK was as easy as destroying the One Ring, the hobbits might never have made it to the big screen.

So, there you have it. Our latest adventure comes to an end. I hope this guide helps you conquer your connection references challenges as efficiently as possible. Remember, in the world of DORKS, there’s always a solution.

Stay tuned for more. DORK out!