Azure Blueprints – Create custom connector for Power Automate

Within Azure, we have a free service called Azure Blueprints. Azure Blueprints helps us in simplify largescale Azure deployments by packaging key environment artifacts, such as Azure Resource Manager templates, role-based access controls, and policies, in a single blueprint definition. Easily apply the blueprint to new subscriptions and environments, and fine-tune control and management through versioning. The Blueprints REST API’s are available to manage the different API groups.

In the last months, I have worked on a proof of concept, using “Low Coding to assign Blueprints definitions in Azure. This includes a PowerApps App and an Automation flow that’s calling the Azure Blueprint REST API. Within Power Automate, calling REST API’s is mostly done by using the HTTP connector.

Custom connector for Power Automate
API Call to assign Blueprint definition

Using the HTTP Connector, give us some overhead because each time you need the steps to get the authorisation token.

Custom connector for Power Automate
Get authorisation token

Creating a custom connector in Power Automate will make life much easier. Let us have a look at the REST API to create or update Assignments.

PUT https://management.azure.com/{scope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}?api-version=2018-11-01-preview

More information about Azure Blueprints REST, can be found here.

Let’s have a look at how I did it and which issues, I had during the creation of the custom connector.

Custom connector for Power Automate
Power Automate

Open Power Automate and select “Data” and click on “Custom connectors”.

Custom connector for Power Automate
+New custom connector

Click “New custom connector” and choose in drop down “Create from blank”.

Custom connector for Power Automate
Create a custom connector

Fill in the connector name and click “Continue”.

Custom connector for Power Automate
Create a custom connector
Custom connector for Power Automate
General Information

The first step of the setup is adding the “General” settings, like uploading icon, set background colour. This colour setting will influence also the top bar of the connector, see examples below.

Custom connector for Power Automate
General Information
Assignments
General Information
Assignments – Get

Detail of the first step (General)

General Information
  1. Image has been uploaded, use PNG or JPG, less then 1MB.
  2. Used background color: #007EE5
  3. Adding a description for the custom connector
  4. Scheme: HTTPS
  5. Host: This information is available in the REST API documentation. https://management.azure.com/{scope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}?api-version=2018-11-01-preview
    Value: “management.azure.com”
  6. Base URL: Because of variables are not allowed the base URL value is “/”

Step 2: Security

This exist out of two part: Azure and the configuration of the custom connector. In Azure, we will create a new app registration and make note of the application id and secret. Adding the Azure Service Management as API permission and push “Grant Admin consent for <Name>” to activate the permissions

Endpoints
Authentication Types

Let go back to the first screenshot:

  1. OAuth2.0 is used to authenticate to the Azure service.
  2. Identity provider: Azure Active Directory
  3. Client id: <APP registration application id >
  4. Client Secret: <APP registration Secret >
  5. Login URL: https://login.windows.net
  6. Tenant ID: Common
  7. Resource URL: https://management.azure.com/ (See that the final slash has been included)
  8. Scope: <n/a>
  9. Redirect URL: Will be create when saving the custom connector for the first time. Copy this URL and go back to the
APP Account

For the APP registration, that we have created in previous step, we will add this copied URI as the “Redirect URIs”.

Step 3: Definition

In the last step, we will create actions based in the REST API list. In this example we will add the get assignments in Azure Blueprints.

Actions

Adding Actions, click “New action”

General

General

  1. Summary, give a name for the action, is displayed as action name in the custom connector.
  2. Description, is shown in the custom connector when selecting the information icon.
  3. Operation ID: This is an unique string used to identify the operation and is internally used into the connector.
Azure blueprints

Adding request for the action and responds of the result.

Test

Click “import from template” and complete the fields at your rights side: GET https://management.azure.com/{scope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}?api-version=2018-11-01-preview

  1. Verb: GET
  2. URL: https://management.azure.com/{scope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}
  3. Headers: n/a
  4. Body: Add body example, see REST API information. Copy the result and paste it in the body.
{
  "identity": {
    "type": "SystemAssigned",
    "tenantId": "00000000-0000-0000-0000-000000000000",
    "principalId": "00000000-0000-0000-0000-000000000000"
  },
  "location": "eastus",
  "properties": {
    "description": "enforce pre-defined simpleBlueprint to this XXXXXXXX subscription.",
    "provisioningState": "succeed",
    "blueprintId": "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint",
    "parameters": {
      "storageAccountType": {
        "value": "Standard_LRS"
      },
      "costCenter": {
        "value": "Contoso/Online/Shopping/Production"
      },
      "owners": {
        "value": [
          "johnDoe@contoso.com",
          "johnsteam@contoso.com"
        ]
      }
    },
    "resourceGroups": {
      "storageRG": {
        "name": "defaultRG",
        "location": "eastus"
      }
    }
  },
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Blueprint/blueprintAssignments/assignSimpleBlueprint",
  "type": "Microsoft.Blueprint/Assignment",
  "name": "assignSimpleBlueprint"
}
Import from sample

Click “Import” to save your input. The request will be filled in based on the input. Some small changes need to be done before, we can say that this has been completed.

Request

Click “scope“, adapt the following settings:

Parameter

Is required: Will add a red star in the beginning of name value.
Visibility: important, this is visible in the connector, when selected.

Assignments – Get

Assignment Name:

Custom connector for Power Automate
assignmentName

API Version:

Custom connector for Power Automate
api-version

Select is required to “Yes” and visibility to internal. This selection will not been shown in the connector action overview, this setting is directly used internally into the custom connector as a default value for this parameter.

Fill in the “Default value” and select “Is required?” to “Yes” and “Visibility” to “Internal”.

Continue to the add responds, see workflow copy an example from the REST API documentation and add in the import from sample window.

Custom connector for Power Automate
Import from Sample
Custom connector for Power Automate
Response

Change the default value to 200.

This is the first action defined into the custom connector:

Custom connector for Power Automate
Request

We can test the connector by clicking on test or by adding the connector into a Flow. Create first a new connection to get the token:

Test operation
Enter values and click “Test operation”
Response

The result of the API request is displayed in the response tab.

Creating a Flow to Get the Assignments of a Azure Blueprint.

Custom connector for Power Automate
Manually trigger a flow

Result after running the flow:

Custom connector for Power Automate
Assignments get

Thanks for reading and please like and share!

About the Author:

It’s started 19 years ago, walking threw all the layers of IT. To become an IT operations consultant (On-premises & Azure infrastructures) and now converting towards a Power Platform Consultant.

2 Years ago, I came in contact with the Microsoft Power Platform and there this passion was born. Outside my work, the Power Platform is always near. Being an active member of the Belgian PowerApps and Flow User Group and share knowledge in the community by writing blogs plus presenting at Power Platform community events in Europe.

My viewpoint is mostly from an operations perspective and this is why you will find Azure resources or services into solutions together with the Power Platform components.

Reference:

Bisback, F. (2019). Azure Blueprints – Create custom connector for Power Automate. Available at: https://blog.pronict.net/2020/01/11/azure-blueprints-create-custom-connector-for-power-automate/ [Accessed: 1st April 2020].

Find more great Power Platform content here.

Share this on...

Rate this Post:

Share: