{"id":24522,"date":"2020-08-28T04:23:45","date_gmt":"2020-08-28T04:23:45","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=24522"},"modified":"2021-12-06T15:13:55","modified_gmt":"2021-12-06T09:43:55","slug":"building-custom-connectors-for-power-apps-and-power-automate-flows-part-1","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2020\/08\/building-custom-connectors-for-power-apps-and-power-automate-flows-part-1\/","title":{"rendered":"Building Custom Connectors for Power Apps and Power Automate Flows \u2013 Part 1"},"content":{"rendered":"<p style=\"text-align: justify;\">Custom logic has until now and still being developed mostly as plugin or workflow assemblies. If you wanted to extend the default behavior of the platform on certain actions like create or update record, you developed either a plugin or workflow and then had to use the Plugin Registration Tool to register this on the appropriate message.<\/p>\n<p style=\"text-align: justify;\">The entire process speaks of pure Dev skills required. Say as a developer you registered the plugin on specific messages and sent it out as part of a solution for the biz users to import and get going from there, but if they needed it now to be registered on another message or entity \u2013 go find the Plugin Registration Tool in XRMToolbox and ask the developer for the steps to get it done.<\/p>\n<p style=\"text-align: justify;\">Step in Power Automate \u2013 the low code \/ no code platform for Biz Users or Citizen Developers as they are sometimes referred to as. Flows are similar to the traditional plugins and workflows that we have had as an option to extend and add custom code\/logic. Flows infact are now being recommended as the preferred option moving forward for your automation needs in Power Platform including the first party apps like Dynamics 365 CE.<\/p>\n<p><strong>Custom Connectors<\/strong> are a way to wrap your biz logic in a container and present it for biz users\u2019 consumption as a simple click, drag, drop interface. If you have worked with Power Apps or Power Automate, you would be familiar with this screen<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-24536\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/1Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"1204\" height=\"1288\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/1Power-Apps-and-Power-Automate-Flows.png 1204w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/1Power-Apps-and-Power-Automate-Flows-280x300.png 280w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/1Power-Apps-and-Power-Automate-Flows-768x822.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/1Power-Apps-and-Power-Automate-Flows-957x1024.png 957w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/1Power-Apps-and-Power-Automate-Flows-660x706.png 660w\" sizes=\"(max-width: 1204px) 100vw, 1204px\" \/><\/p>\n<p style=\"text-align: justify;\">These are connectors to various apps that perform specific actions within those apps and you as a consumer need not know how these have been implemented behind the scenes.<\/p>\n<h2><strong>Azure Functions:<\/strong><\/h2>\n<p style=\"text-align: justify;\">Custom Connectors are a wrapper around Web API or Azure functions. Azure functions in simple terms is your code base hosted on Azure. You can call your code through an http request and it can accept parameters passed either as a query string or the body of the request.<\/p>\n<p>Any Azure function of the type http request, can be consumed directly from Power Automate Flows using the http connector<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-24543\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/pic-of-the-connector.png\" alt=\"\" width=\"1264\" height=\"711\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/pic-of-the-connector.png 599w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/pic-of-the-connector-300x168.png 300w\" sizes=\"(max-width: 1264px) 100vw, 1264px\" \/><\/p>\n<p style=\"text-align: justify;\">Using this connector would however require the user to know and understand, tech concepts like query parameters, headers, body and configuring this is prone to errors especially when handled by citizen developers.<\/p>\n<p>Wrapping this API\/Azure function into a Custom Connector, provides the ability to present the user with an easy to use and configure interface.<\/p>\n<p>Steps to building a connector<\/p>\n<ol>\n<li>Build and host Azure function<\/li>\n<li>Secure the Azure function<\/li>\n<li>Configure the custom connector<\/li>\n<li>Setup the security configuration for your connector<\/li>\n<li>Consume your connector from Power Automate Flows<\/li>\n<\/ol>\n<h2><strong>Build and host Azure Function<\/strong><\/h2>\n<p style=\"text-align: justify;\">You can start designing Azure function right from within Visual Studio 2019<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/2Power-Apps-and-Power-Automate-Flows.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-24535\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/2Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"1796\" height=\"1194\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/2Power-Apps-and-Power-Automate-Flows.png 1796w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/2Power-Apps-and-Power-Automate-Flows-300x199.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/2Power-Apps-and-Power-Automate-Flows-768x511.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/2Power-Apps-and-Power-Automate-Flows-1024x681.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/2Power-Apps-and-Power-Automate-Flows-660x439.png 660w\" sizes=\"(max-width: 1796px) 100vw, 1796px\" \/><\/a><\/p>\n<p>Next choose the Azure Version and Trigger for your function<\/p>\n<p>Set it to Azure Function v2 and choose the Http trigger listed at the end.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/3Power-Apps-and-Power-Automate-Flows.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-24534\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/3Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"1796\" height=\"1194\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/3Power-Apps-and-Power-Automate-Flows.png 1796w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/3Power-Apps-and-Power-Automate-Flows-300x199.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/3Power-Apps-and-Power-Automate-Flows-768x511.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/3Power-Apps-and-Power-Automate-Flows-1024x681.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/3Power-Apps-and-Power-Automate-Flows-660x439.png 660w\" sizes=\"(max-width: 1796px) 100vw, 1796px\" \/><\/a><\/p>\n<p>This sets up the project scaffolding with the default function set up there for use<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/4Power-Apps-and-Power-Automate-Flows.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-24533\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/4Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"3836\" height=\"1360\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/4Power-Apps-and-Power-Automate-Flows.png 3836w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/4Power-Apps-and-Power-Automate-Flows-300x106.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/4Power-Apps-and-Power-Automate-Flows-768x272.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/4Power-Apps-and-Power-Automate-Flows-1024x363.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/4Power-Apps-and-Power-Automate-Flows-660x234.png 660w\" sizes=\"(max-width: 3836px) 100vw, 3836px\" \/><\/a><\/p>\n<p>Believe it or not \u2013 with just this default code, you are actually ready to go! You have a functioning Azure function once deployed to Azure.<\/p>\n<p>We will add additional code here.<\/p>\n<p style=\"text-align: justify;\">Say we are accepting a Tax code as a parameter and will return the Tax Rate. We will read this from CDS entities using the .NET Core SDK currently in alpha.<\/p>\n<p>To begin with, we add reference to the .NET Core SDK assemblies, we will need that to connect to CDS and read the tax rate.<\/p>\n<p>Details on the .NET core assemblies can be found at <u><a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.Powerplatform.Cds.Client\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.nuget.org\/packages\/Microsoft.Powerplatform.Cds.Client<\/a><\/u><\/p>\n<p>While using the Nuget Package Manager make sure to check the pre-release checkbox as this is in alpha at the time of writing this blog<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/5Power-Apps-and-Power-Automate-Flows.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-24532\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/5Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"2212\" height=\"520\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/5Power-Apps-and-Power-Automate-Flows.png 2212w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/5Power-Apps-and-Power-Automate-Flows-300x71.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/5Power-Apps-and-Power-Automate-Flows-768x181.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/5Power-Apps-and-Power-Automate-Flows-1024x241.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/5Power-Apps-and-Power-Automate-Flows-660x155.png 660w\" sizes=\"(max-width: 2212px) 100vw, 2212px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Now lets talk about connecting to CRM environment. Unlike plugin and workflow assemblies where you had access to the execution context, Azure functions as stand-alone functions and therefore you need to explicitly establish connection with CRM to perform read\/write operations.<\/p>\n<p>We will use the Service Principle Name or Application User for connecting. This requires you register an application in Azure and get the Client Id and Secret required for connection.<\/p>\n<p>The following article provides a walkthrough for this<\/p>\n<p><u><a href=\"https:\/\/docs.microsoft.com\/en-us\/powerapps\/developer\/common-data-service\/walkthrough-register-app-azure-active-directory\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/docs.microsoft.com\/en-us\/powerapps\/developer\/common-data-service\/walkthrough-register-app-azure-active-directory<\/a><\/u><\/p>\n<p>Once you have completed the app registration, you are ready to proceed with the connection<\/p>\n<p>We will use the ClientSecret authentication type explained in the article below<\/p>\n<p><u><a href=\"https:\/\/docs.microsoft.com\/en-us\/dynamics365\/customerengagement\/on-premises\/developer\/xrm-tooling\/use-connection-strings-xrm-tooling-connect\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/docs.microsoft.com\/en-us\/dynamics365\/customerengagement\/on-premises\/developer\/xrm-tooling\/use-connection-strings-xrm-tooling-connect<\/a><\/u><\/p>\n<p>\/\/set the connection string<\/p>\n<p>connectionString = @&#8221; AuthType = ClientSecret; url = &#8221;<\/p>\n<p>+ url + &#8220;; &#8221; + \/\/https:\/\/xxx.crm8.dynamics.com;<\/p>\n<p>&#8221; ClientId = &#8221; + clientId + &#8220;; &#8221;<\/p>\n<p>&#8221; ClientSecret = &#8221; + clientSecret;<\/p>\n<p>\/\/establish connection with CDS<\/p>\n<p>CdsServiceClient client = new CdsServiceClient(connectionString);<\/p>\n<p>The .NET Core assemblies follow the same syntax and functions as the sdk assemblies except the change in the namespace this ensure no additional learning curve to make use of these assemblies.<\/p>\n<p>Now go ahead read the tax and return this as a JSON object<\/p>\n<p>\/\/check if result found<\/p>\n<p>if (coll != null &amp;&amp; coll.Entities.Count &gt; 0)<\/p>\n<p>{<\/p>\n<p style=\"padding-left: 40px;\">rate = (double) coll.Entities[0][&#8220;msdyn_taxrate&#8221;];<\/p>\n<p style=\"padding-left: 40px;\">dynamic resultobj = new {<\/p>\n<p style=\"padding-left: 40px;\">rate = (double)coll.Entities[0][&#8220;msdyn_taxrate&#8221;],<\/p>\n<p style=\"padding-left: 40px;\">isproducttaxable = (bool)coll.Entities[0][&#8220;msdyn_productstaxable&#8221;],<\/p>\n<p style=\"padding-left: 40px;\">aadid = resp.UserId.ToString()<\/p>\n<p style=\"padding-left: 40px;\">};<\/p>\n<p style=\"padding-left: 40px;\">result = JsonConvert.SerializeObject(resultobj);<\/p>\n<p>}<\/p>\n<p style=\"text-align: justify;\">Publish this function to Azure, you could do this from right within Visual Studio. Choose Publish and provide all the connection details to the azure environment.<\/p>\n<p>Once published, you should see a function app and the function listed in there, similar to the screenshot below<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/6Power-Apps-and-Power-Automate-Flows.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-24531\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/6Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"2998\" height=\"854\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/6Power-Apps-and-Power-Automate-Flows.png 2998w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/6Power-Apps-and-Power-Automate-Flows-300x85.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/6Power-Apps-and-Power-Automate-Flows-768x219.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/6Power-Apps-and-Power-Automate-Flows-1024x292.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/6Power-Apps-and-Power-Automate-Flows-660x188.png 660w\" sizes=\"(max-width: 2998px) 100vw, 2998px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">This function once published is now ready to be called. But before that, lets ensure that not just about anybody can call function. This can be done at the simplest level by enabling function keys<\/p>\n<p>Function keys could be created that would need to be passed with every call to the function to authenticate itself. If the key is missing or does not match the keys defined in Function keys, the request is not executed.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/7Power-Apps-and-Power-Automate-Flows.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-24530\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/7Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"1804\" height=\"802\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/7Power-Apps-and-Power-Automate-Flows.png 1804w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/7Power-Apps-and-Power-Automate-Flows-300x133.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/7Power-Apps-and-Power-Automate-Flows-768x341.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/7Power-Apps-and-Power-Automate-Flows-1024x455.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/7Power-Apps-and-Power-Automate-Flows-660x293.png 660w\" sizes=\"(max-width: 1804px) 100vw, 1804px\" \/><\/a><\/p>\n<p>To get the url to the request for testing, use the Get Function URL button<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/Power-Apps-and-Power-Automate-Flows.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-24537\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"1436\" height=\"390\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/Power-Apps-and-Power-Automate-Flows.png 1436w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/Power-Apps-and-Power-Automate-Flows-300x81.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/Power-Apps-and-Power-Automate-Flows-768x209.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/Power-Apps-and-Power-Automate-Flows-1024x278.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/Power-Apps-and-Power-Automate-Flows-660x179.png 660w\" sizes=\"(max-width: 1436px) 100vw, 1436px\" \/><\/a><\/p>\n<p>Copy and paste this URL in Postman to test the function.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/8Power-Apps-and-Power-Automate-Flows.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-24529\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/8Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"1930\" height=\"739\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/8Power-Apps-and-Power-Automate-Flows.png 1930w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/8Power-Apps-and-Power-Automate-Flows-300x115.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/8Power-Apps-and-Power-Automate-Flows-768x294.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/8Power-Apps-and-Power-Automate-Flows-1024x392.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/8Power-Apps-and-Power-Automate-Flows-660x253.png 660w\" sizes=\"(max-width: 1930px) 100vw, 1930px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Now for our connector, we would like to provide the ability for the user to login to their AAD account, similar to the experience that we have when using the CDS connector.<\/p>\n<h2><strong>Secure the Azure Function<\/strong><\/h2>\n<p>For this let us start with setting up the authentication for the Azure function.<\/p>\n<p>Navigate to the Authentication \/ Authorization found under settings in the function app and enable App Service authentication and set it to Login with Azure AAD<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/9Power-Apps-and-Power-Automate-Flows.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-24528\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/9Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"1778\" height=\"980\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/9Power-Apps-and-Power-Automate-Flows.png 1778w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/9Power-Apps-and-Power-Automate-Flows-300x165.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/9Power-Apps-and-Power-Automate-Flows-768x423.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/9Power-Apps-and-Power-Automate-Flows-1024x564.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/9Power-Apps-and-Power-Automate-Flows-660x364.png 660w\" sizes=\"(max-width: 1778px) 100vw, 1778px\" \/><\/a><\/p>\n<p>Choose Azure Active Directory from the list of Authentication Providers.<\/p>\n<p>You are navigated to the next screen where we need to choose an App Registration<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/10Power-Apps-and-Power-Automate-Flows.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-24527\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/10Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"1778\" height=\"980\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/10Power-Apps-and-Power-Automate-Flows.png 1778w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/10Power-Apps-and-Power-Automate-Flows-300x165.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/10Power-Apps-and-Power-Automate-Flows-768x423.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/10Power-Apps-and-Power-Automate-Flows-1024x564.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/10Power-Apps-and-Power-Automate-Flows-660x364.png 660w\" sizes=\"(max-width: 1778px) 100vw, 1778px\" \/><\/a><\/p>\n<p>Register a new APP for Azure function AAD authentication. Steps are similar to the app registration done before for CRM connection. Except you do not have to create a user in CRM and we do not need to provide API permissions to CRM.<\/p>\n<p>In the Authentication option while creating the APP registration choose Multi-tenant option. as shown below<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/11Power-Apps-and-Power-Automate-Flows.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-24526\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/11Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"1896\" height=\"1114\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/11Power-Apps-and-Power-Automate-Flows.png 1896w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/11Power-Apps-and-Power-Automate-Flows-300x176.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/11Power-Apps-and-Power-Automate-Flows-768x451.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/11Power-Apps-and-Power-Automate-Flows-1024x602.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/11Power-Apps-and-Power-Automate-Flows-660x388.png 660w\" sizes=\"(max-width: 1896px) 100vw, 1896px\" \/><\/a><\/p>\n<p>The API permissions screen should appear similar to the following<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/12Power-Apps-and-Power-Automate-Flows.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-24525\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/12Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"2708\" height=\"850\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/12Power-Apps-and-Power-Automate-Flows.png 2708w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/12Power-Apps-and-Power-Automate-Flows-300x94.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/12Power-Apps-and-Power-Automate-Flows-768x241.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/12Power-Apps-and-Power-Automate-Flows-1024x321.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/12Power-Apps-and-Power-Automate-Flows-660x207.png 660w\" sizes=\"(max-width: 2708px) 100vw, 2708px\" \/><\/a><\/p>\n<p>Choose this APP in the Azure Active Directory Authentication screen above.<\/p>\n<p><strong><em>Since we need to make sure our Azure function available from different tenants, make this change<\/em><\/strong><\/p>\n<p>Navigate back to Azure function \u00e0 Authentication \/ Authorization<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/13Power-Apps-and-Power-Automate-Flows.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-24524\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/13Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"1340\" height=\"1134\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/13Power-Apps-and-Power-Automate-Flows.png 1340w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/13Power-Apps-and-Power-Automate-Flows-300x254.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/13Power-Apps-and-Power-Automate-Flows-768x650.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/13Power-Apps-and-Power-Automate-Flows-1024x867.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/13Power-Apps-and-Power-Automate-Flows-660x559.png 660w\" sizes=\"(max-width: 1340px) 100vw, 1340px\" \/><\/a><\/p>\n<p>Click on the Azure Active Directory and switch from Express to Advanced<\/p>\n<p>This should bring up the below screen with the Client Id of your selected app already pre-set along with the issuer url.<\/p>\n<p>To make this multi-tenant \u2013 CLEAR the Issuer URL and save.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/14Power-Apps-and-Power-Automate-Flows.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-24523\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/14Power-Apps-and-Power-Automate-Flows.png\" alt=\"Power Apps and Power Automate Flows\" width=\"1340\" height=\"692\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/14Power-Apps-and-Power-Automate-Flows.png 1340w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/14Power-Apps-and-Power-Automate-Flows-300x155.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/14Power-Apps-and-Power-Automate-Flows-768x397.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/14Power-Apps-and-Power-Automate-Flows-1024x529.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2020\/08\/14Power-Apps-and-Power-Automate-Flows-660x341.png 660w\" sizes=\"(max-width: 1340px) 100vw, 1340px\" \/><\/a><\/p>\n<p>Ref: <a href=\"https:\/\/docs.microsoft.com\/en-us\/sharepoint\/dev\/spfx\/use-aadhttpclient-enterpriseapi-multitenant\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/docs.microsoft.com\/en-us\/sharepoint\/dev\/spfx\/use-aadhttpclient-enterpriseapi-multitenant<\/a><\/p>\n<p>Now if you try to execute the function through Postman you will receive an authentication error. You will need to provide authentication token to be able to execute this.<\/p>\n<p>The next step is to create the wrapper around this function. We will check the steps to create a custom connector in the <a href=\"https:\/\/www.inogic.com\/blog\/2020\/08\/building-custom-connectors-for-power-apps-and-power-automate-flows-part-2\/\" target=\"_blank\" rel=\"noopener noreferrer\">next part<\/a>.<\/p>\n<h2 style=\"text-align: left;\"><div class=\"su-heading su-heading-style-default su-heading-align-center\" id=\"\" style=\"font-size:15px;margin-bottom:5px\"><div class=\"su-heading-inner\">One Pic = 1000 words! Analyze data 90% faster with visualization apps!<\/div><\/div><\/h2>\n<p style=\"text-align: left;\"><em>Get optimum visualization of Dynamics 365 CRM data with &#8211;<\/em><br \/>\n<em><strong><a href=\"https:\/\/bit.ly\/3lYvozZ\" target=\"_blank\" rel=\"noopener noreferrer\">Kanban Board<\/a> <\/strong>\u2013 Visualize Dynamics 365 CRM data in Kanban view by categorizing entity records in lanes and rows as per their status, priority, etc.<\/em><br \/>\n<em><strong><a href=\"https:\/\/bit.ly\/3lCSBaA\" target=\"_blank\" rel=\"noopener noreferrer\">Map My Relationships<\/a><\/strong> \u2013 Map My Relationships \u2013 Visualize connections and relationships between Dynamics 365 CRM entities or related records in a Mind Map view.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Custom logic has until now and still being developed mostly as plugin or workflow assemblies. If you wanted to extend the default behavior of the platform on certain actions like create or update record, you developed either a plugin or workflow and then had to use the Plugin Registration Tool to register this on the\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2020\/08\/building-custom-connectors-for-power-apps-and-power-automate-flows-part-1\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":24538,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2088,18,36,44,1985],"tags":[2089,1337,1989],"class_list":["post-24522","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-custom-connector","category-dynamics-365-v9-2","category-microsoft-flow","category-power-apps","category-power-automate","tag-custom-connector","tag-power-apps","tag-power-automate-flows"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/24522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=24522"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/24522\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/24538"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=24522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=24522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=24522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}