This tutorial demonstrates how to register a Swagger file describing an Azure Resource Manager (ARM) API and then connect to it in PowerApps.
First, we need to create an Azure Active Directory (AAD) application that will perform the authentication when calling the ARM API endpoint.
Sign in to the Azure portal. If you have more than one Azure Active Directory tenant, make sure you're logged into the correct directory by looking at your username in the upper-right corner.
On the left-hand menu, click More services. In the Filter textbox, type Azure Active Directory, and then click Azure Active Directory.
The Azure Active Directory blade opens.
In the menu on the Azure Active Directory blade, click App registrations.
In the list of registered applications, click Add.
Type a name for your application, leave Web app / API selected, and then for Sign-on URL type
https://login.windows.net. Click Create.
Click the new application in the list.
The Registered app blade opens. Make a note of the Application ID. We'll need it later.
The Settings blade should have opened, as well. If it didn't, click the Settings button.
In the Settings blade, click Reply URLs. In the list of URLs, add
https://msmanaged-na.consent.azure-apim.net/redirect and click Save.
Back on the Settings blade, click Required permissions. On the Required permissions blade, click Add.
The Add API access blade opens.
Click Select an API. In the blade that opens, click the option for the Azure Service Management API and click Select.
Click Select permissions. Under Delegated permissions, click Access Azure Service Management as organization users, and then click Select.
On the Add API access blade, click Done.
Back on the Settings blade, click Keys. In the Keys blade, type a description for your key, select an expiration period, and then click Save. Your new key will be displayed. Make note of the key value, as we will need that later, too. You may now close the Azure portal.
Now that the AAD application is configured, let's add the custom API.
In powerapps.com, in the menu on the left, click Connections. Then click New connection in the upper-right corner.
Click Custom to display your list of custom connections, and then click New custom API.
Type a Name for your connection, and then upload the sample ARM Swagger file. Click Next.
On the next screen, because the Swagger file uses our AAD application for authentication, we need to give PowerApps some information about our application. Under Client id, type the AAD Application ID you noted earlier. For client secret, use the key. And finally, for Resource URL, type
Your custom API is now registered and can be consumed within PowerApps or Microsoft Flow.
The sample Swagger does not define the full set of ARM operations and currently only contains the List all subscriptions operation. You can edit this Swagger or create another Swagger file using the online Swagger editor.
This process can be used to access any RESTful API authenticated using AAD.
For more detailed information about how to create an app, see Create an app from data.
For more detailed information about how to use a flow in an app, see Start a flow in an app.
To ask questions or make comments about custom APIs, join our community.