When working with the paconn
CLI tool to create and manage custom connectors in the Power Platform, it’s essential to configure your environment settings properly, especially when targeting different government cloud environments like GCC, GCC High, and DoD. In this article, we’ll guide you through setting up these configurations, including creating a connectionSettings.json
file for each environment, downloading a custom connector, and updating the connector’s settings for seamless management.
paconn
CLI tool installed. You can install it using Python’s pip:
pip install paconn
Begin by registering an application in Azure Active Directory (Azure AD) that will serve as the identity for your paconn
operations.
Navigate to Azure AD: Sign in to the Azure portal and go to Azure Active Directory.
Create a New App Registration:
API Permissions:
The app automatically includes the User.Read
permission under Microsoft Graph. No additional API permissions are needed.
Allow Public Client Flows:
Under Authentication > Advanced settings, set Allow public client flows to Yes. This enables the device code flow, which paconn
uses for authentication.
Copy Your IDs:
After registering the application, go to the Overview section.
Copy the Application (client) ID and Directory (tenant) ID. These values will be used in the connectionSettings.json
file in the next step.
By the end of this step, you should have your Application (client) ID and Directory (tenant) ID ready for configuring the connection settings in the following step.
connectionSettings.json
FileNext, you’ll create a connectionSettings.json
file with specific values tailored for each environment. This file is crucial for authenticating and operating within your selected cloud.
{
"powerAppsUrl": "https://gov.api.powerapps.us/",
"flowUrl": "https://gov.api.flow.microsoft.us/",
"resource": "https://gov.service.powerapps.us/",
"authorityUrl": "https://login.microsoftonline.com/",
"clientId": "<Your Application (client) ID>",
"tenant": "<Your Directory (tenant) ID>"
}
{
"powerAppsUrl": "https://high.api.powerapps.us/",
"flowUrl": "https://high.api.flow.microsoft.us/",
"resource": "https://high.service.powerapps.us/",
"authorityUrl": "https://login.microsoftonline.us/",
"clientId": "<Your Application (client) ID>",
"tenant": "<Your Directory (tenant) ID>"
}
{
"powerAppsUrl": "https://api.apps.appsplatform.us/",
"flowUrl": "https://api.flow.appsplatform.us/",
"resource": "https://service.apps.appsplatform.us/",
"authorityUrl": "https://login.microsoftonline.us/",
"clientId": "<Your Application (client) ID>",
"tenant": "<Your Directory (tenant) ID>"
}
Replace <Your Application (client) ID>
and <Your Directory (tenant) ID>
with the values from your Azure App Registration.
Once you’ve configured your connectionSettings.json
file with the correct values for your environment, the next step is to log in to the paconn
CLI tool. This authentication process is essential for performing any subsequent operations with the tool.
To log in, use the following command:
paconn login --settings connectionSettings.json
This command initiates the login process. Follow the prompts to authenticate using the device code flow. Once logged in, you’ll be ready to download and manage your custom connectors.
After successfully logging in, you can download an existing custom connector from your environment. This process involves selecting the environment and the specific connector you want to work with.
Run the following command:
paconn download --settings connectionSettings.json
This command will prompt you to choose the environment based on your connectionSettings.json
file. After selecting the environment, you’ll be able to choose the connector you wish to download. The connector will be saved locally, along with a settings.json
file.
Once you have downloaded the connector, you may need to update it. The settings.json
file downloaded with the connector needs to include the same settings you have in your connectionSettings.json
file. This ensures consistency when managing or updating the connector.
Here’s what you need to do:
Open the Downloaded settings.json
File: Locate the file that was downloaded along with the connector.
Update the Fields: Add or update the following fields with the values from your connectionSettings.json
:
{
"powerAppsUrl": "https://high.api.powerapps.us/",
"flowUrl": "https://high.api.flow.microsoft.us/",
"resource": "https://high.service.powerapps.us/",
"authorityUrl": "https://login.microsoftonline.us/",
"clientId": "<Your Application (client) ID>",
"tenant": "<Your Directory (tenant) ID>"
}
Save the File: Ensure all changes are saved.
To apply the updates to the connector, run:
paconn update --settings settings.json
This command will push the changes to the connector in the selected environment.
Creating a new custom connector follows a similar process to updating an existing one, but with a few differences. Since it’s a new connector, you don’t need to include all the same properties in the settings.json
file.
Here’s an example of a settings.json
file for a new connector:
{
"environment": "d9f0b637-5539-e256-9232-ecb5839cdb02",
"apiProperties": "apiProperties.json",
"apiDefinition": "apiDefinition.swagger.json",
"icon": "icon.png",
"powerAppsUrl": "https://high.api.powerapps.us/",
"flowUrl": "https://high.api.flow.microsoft.us/",
"authorityUrl": "https://login.microsoftonline.us/",
"resource": "https://high.service.powerapps.us/",
"clientId": "<Your Application (client) ID>",
"tenant": "<Your Directory (tenant) ID>"
}
Key Differences:
connectorId
: Since this is a new connector, you don’t need to include the connectorId
property.script
Property: If you aren’t including custom code, you can omit the script
property from the settings.json
file.Once the settings.json
file is ready, you can create the new connector with the following command:
paconn create --settings settings.json
This will create a new custom connector in your specified environment using the provided settings.
When working with government cloud environments like GCC, GCC High, and DoD, it’s essential to consistently use settings.json
files for your operations with the paconn
CLI tool. This is because attempting to mix the --settings
option with other command-line arguments like --api-prop
and --api-def
will not work as expected.
To ensure smooth operations:
connectionSettings.json
file at your project root: This file should contain the basic authentication and environment details.settings.json
file for each connector: Tailor it with the specific details for each connector you manage.By following this approach, you’ll be able to effectively use the paconn
CLI tool to manage connectors across various government cloud environments.
It’s also worth noting that while the PAC CLI tool also supports commands for managing connectors, it is relatively new and still has some bugs. Until these issues are resolved, I recommend continuing with the paconn
method described here. However, the PAC CLI tool does offer a much easier way to connect to these clouds, so I’m optimistic about its potential in the future.
Original Post http://www.richardawilson.com/2024/08/connecting-paconn-cli-tool-to-gcc-gcch.html