{"id":2721,"date":"2024-05-21T06:28:11","date_gmt":"2024-05-21T13:28:11","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/semantic-kernel\/?p=2721"},"modified":"2024-05-21T06:28:11","modified_gmt":"2024-05-21T13:28:11","slug":"connect-logic-apps-1400-connectors-to-semantic-kernel","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/agent-framework\/connect-logic-apps-1400-connectors-to-semantic-kernel\/","title":{"rendered":"Connect Logic Apps&#8217; 1,400 connectors to Semantic Kernel"},"content":{"rendered":"<p class=\"code-line\" dir=\"auto\" data-line=\"2\">At the heart of every company are custom APIs that are built to solve specific business problems. These APIs often use Logic Apps, which is a powerful way to build APIs\u00a0<em>without writing code<\/em>. With Logic Apps&#8217; over 1,400 enterprise connectors, you can connect to your enterprise systems, transform data, and automate processes to solve your business needs.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"4\">We&#8217;ve seen customers build Logic Apps to help&#8230;<\/p>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"5\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"5\">Automate development processes<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"6\">Connect to legacy systems<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"7\">Integrate with third-party services<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"8\">And more!<\/li>\n<\/ul>\n<p class=\"code-line\" dir=\"auto\" data-line=\"10\">Often, however, using these APIs is still a manual process. End-users need to visit websites, fill out forms, and wait for responses. What if instead, AI agents could interact with these APIs on behalf of the end-users? This is where Semantic Kernels come in.<\/p>\n<h2 id=\"semantic-kernels-plugins\" class=\"code-line\" dir=\"auto\" data-line=\"12\">Semantic Kernel&#8217;s plugins<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"13\">Within Semantic Kernel, it&#8217;s possible to create plugins that interact with any logic, whether its native code or an API. To make it even easier to import APIs as plugins, we&#8217;ve provided a simple import method (across all three SDKs) that takes any OpenAPI specified API and converts it into a plugin.<\/p>\n<p dir=\"auto\" data-line=\"13\"><strong>C#<\/strong><\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">await kernel.ImportPluginFromOpenApiAsync(\r\n    pluginName: \"openapi_plugin\",\r\n    uri: new Uri(\"https:\/\/githubworkflowsplugin.azurewebsites.net\/swagger.json\"),\r\n    executionParameters: new OpenApiFunctionExecutionParameters()\r\n    {\r\n        ServerUrlOverride = new Uri(lightPluginEndpoint),\r\n        EnablePayloadNamespacing = true\r\n    }\r\n).Wait();<\/code><\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"prettyprint language-py\"><code class=\"language-py\">await kernel.add_plugin_from_openai(\r\n    plugin_name=\"openapi_plugin\",\r\n    plugin_url=\"https:\/\/githubworkflowsplugin.azurewebsites.net\/swagger.json\",\r\n    execution_settings=OpenAPIFunctionExecutionParameters(\r\n        http_client=http_client,\r\n        enable_payload_namespacing=True,\r\n    ),\r\n)<\/code><\/pre>\n<p><strong>Java<\/strong><\/p>\n<pre class=\"prettyprint language-java\"><code class=\"language-java\">\/\/ Available as a sample at https:\/\/github.com\/microsoft\/semantic-kernel\/tree\/java-v1\/java\/samples\/semantickernel-openapi-plugin\r\n\r\nKernelPlugin openAPIPlugin = SemanticKernelOpenAPIImporter\r\n    .builder()\r\n    .withPluginName(\"light_plugin\")\r\n    .withServer(\"https:\/\/githubworkflowsplugin.azurewebsites.net\")\r\n    .withSchema(swaggerSchema)\r\n    .build();\r\n\r\nKernel kernel = Kernel.builder()\r\n    .withAIService(ChatCompletionService.class, chat)\r\n    .withPlugin(openAPIPlugin)\r\n    .build();<\/code><\/pre>\n<p class=\"code-line\" dir=\"auto\" data-line=\"54\">This means you only need to author an API\u00a0<em>once<\/em>\u00a0and then you can use it in any language.<\/p>\n<h2 id=\"you-can-now-import-logic-apps-as-plugins\" class=\"code-line\" dir=\"auto\" data-line=\"56\">You can now import Logic Apps as plugins<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"57\">Because Logic Apps now supports OpenAPI specifications\u00a0<em>and<\/em>\u00a0the OpenAI plugin manifest, you can easily take any of the APIs you have previously built and import them as a plugin. To enable this functionality, you simply need to update your host.json file to include two new unauthorized endpoints:<\/p>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"59\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"59\">\/.well-known\/ai-plugin.json<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"60\">\/swagger.json<\/li>\n<\/ul>\n<p class=\"code-line\" dir=\"auto\" data-line=\"62\">Afterwards, you can apply EasyAuth to your individual APIs to secure them so that they can be used with Semantic Kernel.<\/p>\n<h2 id=\"building-a-github-copilot-with-logic-apps-and-semantic-kernel\" class=\"code-line\" dir=\"auto\" data-line=\"64\">Building a GitHub Copilot with Logic Apps and Semantic Kernel<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"65\">Many customers today already have Logic Apps that help them manage their GitHub repositories and build automation processes. With Semantic Kernel, you can now take these same Logic Apps and give to your AI agents as tools. This means your AI agents can now help you identify PRs that need attention, explain why a build failed, and even help you write code.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"67\">As part of our push to v1 for each of our SDKs, we created a Logic App that would help us identify differences between our implementations. This included building the following workflows:<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"69\"><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/05\/Screenshot-2024-05-20-at-7.12.04\u202fPM.png\"><img decoding=\"async\" class=\"aligncenter size-large wp-image-2722\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/05\/Screenshot-2024-05-20-at-7.12.04\u202fPM-1024x634.png\" alt=\"Image Screenshot 2024 05 20 at 7 12 04 PM\" width=\"640\" height=\"396\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/05\/Screenshot-2024-05-20-at-7.12.04\u202fPM-1024x634.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/05\/Screenshot-2024-05-20-at-7.12.04\u202fPM-300x186.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/05\/Screenshot-2024-05-20-at-7.12.04\u202fPM-768x475.png 768w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/05\/Screenshot-2024-05-20-at-7.12.04\u202fPM-1536x950.png 1536w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/05\/Screenshot-2024-05-20-at-7.12.04\u202fPM.png 1726w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"71\">Each workflow helps automate a different part of the development process:<\/p>\n<ul class=\"code-line\" dir=\"auto\" data-line=\"72\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"72\"><strong>Search files<\/strong>\u00a0\u2013 to find code snippets that are relevant to a given problem<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"73\"><strong>Get file<\/strong>\u00a0\u2013 to retrieve the contents of a file in the GitHub repository<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"74\"><strong>Get PR details<\/strong>\u00a0\u2013 to retrieve the details of a PR (e.g., the PR title, description, and author)<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"75\"><strong>Get PR files<\/strong>\u00a0\u2013 to retrieve the files that were changed in a PR<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"76\"><strong>Get build and test failures<\/strong>\u00a0\u2013 to retrieve the build and test failures for a given GitHub action run<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"77\"><strong>Get log file<\/strong>\u00a0\u2013 to retrieve the log file for a given GitHub action run<\/li>\n<\/ul>\n<p class=\"code-line\" dir=\"auto\" data-line=\"79\">The most complicated of these Logic Apps (Get build and test failures) would have traditionally required a developer to write hundreds of lines of code, but with Logic Apps, it&#8217;s as simple as dragging and dropping connectors to retrieve the necessary information, parse it, and return the specific problems identified in the build. This increases the speed at which you can build these APIs for users\u00a0<em>and as of today<\/em>\u00a0increases the speed at which you can augment the capabilities of your AI agents.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"85\">After importing these APIs into Semantic Kernel, our agent can now use them to 1) explain concepts in Semantic Kernel, 2) identify issues in PRs, and 3) help write code. Below is a\u00a0<em>real<\/em>\u00a0transcript of a conversation between a developer and the AI agent:<\/p>\n<blockquote style=\"border-color: #339966;\"><p><span style=\"color: #339966;\"><strong>User<\/strong><\/span><\/p>\n<p>I&#8217;m reviewing https:\/\/github.com\/microsoft\/semantic-kernel\/pull\/6318, can you quickly summarize what&#8217;s changing?<\/p><\/blockquote>\n<blockquote style=\"border-color: #3366ff;\"><p><span style=\"color: #3366ff;\"><strong>ToolCall<\/strong><\/span><\/p>\n<p>GitHub_GetFilesInPR_API_invoke({&#8220;pr&#8221;:&#8221;6318&#8243;})<\/p><\/blockquote>\n<blockquote style=\"border-color: #800000;\"><p><span style=\"color: #800000;\"><strong>Assistant<\/strong><\/span><\/p>\n<p>The PR #6318 in the Semantic Kernel repository has several changes primarily focusing on integration tests and some enhancement to plugins and settings. Here&#8217;s a summary of what&#8217;s changing:<\/p>\n<p><strong>Updated Files<\/strong><\/p>\n<ol>\n<li><strong>Integration Test Data Updates and Additions:<\/strong>\n<ul>\n<li>Various JSON data files for expected results in tests (`prompt_with_chat_roles_expected.json`, `light_bulb_api.json`, `prompt_simple_expected.json`, etc.)<\/li>\n<li>YAML test configuration files (`simple_prompt_test.yaml`, `prompt_with_chat_roles_test_j2.yaml`, etc.)<\/li>\n<\/ul>\n<\/li>\n<li><strong>Test Scripts:<\/strong>\n<ul>\n<li>Updated the main testing script for cross-language integration tests (`test_cross_language.py`).<\/li>\n<\/ul>\n<\/li>\n<li><strong>Connector and Plugin Enhancements:<\/strong>\n<ul>\n<li>Enhanced the Open AI prompt execution settings module (`open_ai_prompt_execution_settings.py`).<\/li>\n<li>Provided a new plugin sample using OpenAI with Azure Key Vault integration (`openai_plugin_azure_key_vault.py`).<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>This PR appears to focus on enhancing testing infrastructure and slight modifications in connectors and plugin configurations to support broader or more specific test scenarios and security features.<\/p><\/blockquote>\n<blockquote style=\"border-color: #339966;\"><p><span style=\"color: #339966;\"><strong>User<\/strong><\/span><\/p>\n<p>Can you tell me how the execution settings are changing compared to main?<\/p><\/blockquote>\n<blockquote style=\"border-color: #3366ff;\"><p><span style=\"color: #3366ff;\"><strong>ToolCall<\/strong><\/span><\/p>\n<p>GitHub_GetFile_API_invoke({&#8220;file_path&#8221;:&#8221;python\/semantic_kernel\/connectors\/ai\/open_ai\/prompt_execution_settings\/open_ai_prompt_execution_settings.py&#8221;,&#8221;ref&#8221;:&#8221;heads\/main&#8221;,&#8221;repo&#8221;:&#8221;microsoft\/semantic-kernel&#8221;})<\/p><\/blockquote>\n<blockquote style=\"border-color: #3366ff;\"><p><span style=\"color: #3366ff;\"><strong>ToolCall<\/strong><\/span><\/p>\n<p>GitHub_GetFile_API_invoke({&#8220;file_path&#8221;:&#8221;python\/semantic_kernel\/connectors\/ai\/open_ai\/prompt_execution_settings\/open_ai_prompt_execution_settings.py&#8221;,&#8221;ref&#8221;:&#8221;pull\/6318\/head&#8221;,&#8221;repo&#8221;:&#8221;microsoft\/semantic-kernel&#8221;})<\/p><\/blockquote>\n<blockquote style=\"border-color: #800000;\"><p><span style=\"color: #800000;\"><strong>Assistant<\/strong><\/span><\/p>\n<p>The changes in the `OpenAIPromptExecutionSettings` in the PR relative to the main branch involve several flexibility enhancements and adjustments to default values, providing a more dynamic and optionally specified configuration. Here are the primary changes:<\/p>\n<ol>\n<li><strong>Type Adjustments and Optional Fields:\n<\/strong><\/p>\n<ul>\n<li>Many fields such as `ai_model_id`, `frequency_penalty`, `logit_bias`, `max_tokens`, `number_of_responses`, `presence_penalty`, `seed`, `temperature`, and `top_p` have been changed to either `Optional` or introduced type unions allowing for `None` values. This permits these parameters to be unspecified, enhancing default handling and dynamic configuration.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Removal of Fixed Default Values:<\/strong>\n<ul>\n<li>Default values for fields like `frequency_penalty`, `temperature`, `top_p`, and others have been removed, suggesting that these settings will either be inherited from a broader context or will need explicit specification when used.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Consistency and Validation Logic:<\/strong>\n<ul>\n<li>The internal validation within the settings class remains consistent, ensuring logical correctness when both `best_of` and `number_of_responses` settings are used together.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>These changes suggest a move towards more adaptable and potentially context-dependent execution settings for OpenAI integrations in Semantic Kernel, likely aiming to accommodate a wider range of scenarios or simpler integration without cumbersome mandatory settings.<\/p><\/blockquote>\n<blockquote style=\"border-color: #339966;\"><p><span style=\"color: #339966;\"><strong>User<\/strong><\/span><\/p>\n<p>Can you compare this with the .NET implementation? Are the behaviors the same?<\/p><\/blockquote>\n<blockquote style=\"border-color: #3366ff;\"><p><span style=\"color: #3366ff;\"><strong>ToolCall<\/strong><\/span><\/p>\n<p>GitHub_SearchFiles_API_invoke({&#8220;language&#8221;:&#8221;c#&#8221;,&#8221;query&#8221;:&#8221;OpenAIPromptExecutionSettings&#8221;,&#8221;ref&#8221;:&#8221;heads\/main&#8221;})<\/p><\/blockquote>\n<blockquote style=\"border-color: #3366ff;\"><p><span style=\"color: #3366ff;\"><strong>ToolCall<\/strong><\/span><\/p>\n<p>GitHub_GetFile_API_invoke({&#8220;file_path&#8221;:&#8221;dotnet\/src\/Connectors\/Connectors.OpenAI\/OpenAIPromptExecutionSettings.cs&#8221;,&#8221;ref&#8221;:&#8221;heads\/main&#8221;,&#8221;repo&#8221;:&#8221;microsoft\/semantic-kernel&#8221;})<\/p><\/blockquote>\n<blockquote style=\"border-color: #800000;\"><p><span style=\"color: #800000;\"><strong>Assistant<\/strong><\/span><\/p>\n<p>The .NET implementation of `OpenAIPromptExecutionSettings` in the Semantic Kernel significantly aligns with the Python version in functionality but exhibits some differences in structure and additional behaviors:<\/p><\/blockquote>\n<blockquote style=\"border-color: #800000;\"><p><span style=\"color: #800000;\"><strong>Assistant<\/strong><\/span><\/p>\n<p><strong>Similarities:<\/strong><\/p>\n<ol>\n<li><strong>Parametrization:<\/strong>\u00a0Both implementations provide parameters like `Temperature`, `TopP`, `PresencePenalty`, `FrequencyPenalty`, `MaxTokens`, and setup for `StopSequences`.<\/li>\n<li><strong>Dynamism:<\/strong> They allow flexibility with optional or nullable parameters, enabling dynamic configuration based on varying conditions.<\/li>\n<li><strong>Validation and Adaptation:<\/strong> Both are designed to ensure logical and functional validation for parameter interactions, keeping the behavior similar across executions.<\/li>\n<\/ol>\n<p>&#8230;.<\/p><\/blockquote>\n<h2 id=\"getting-started\" class=\"code-line\" dir=\"auto\" data-line=\"159\">Getting started<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"160\">To get started, you can follow the steps below to import your Logic Apps as plugins into Semantic Kernel:<\/p>\n<ol class=\"code-line\" dir=\"auto\" data-line=\"161\">\n<li class=\"code-line\" dir=\"auto\" data-line=\"161\">Enable metadata endpoints for Logic App<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"162\">Configure your application for Easy Auth<\/li>\n<li class=\"code-line\" dir=\"auto\" data-line=\"163\">Use Logic Apps with Semantic Kernel as a plugin<\/li>\n<\/ol>\n<h3 id=\"enable-metadata-endpoints-for-logic-app\" class=\"code-line\" dir=\"auto\" data-line=\"165\">Enable metadata endpoints for Logic App<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"166\">For the easiest setup, you can enable unauthenticated access to the metadata endpoints for your Logic App. This will allow you to import your Logic App as a plugin into Semantic Kernel without needing to create a custom HTTP client to handle authentication for the initial import.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"168\">The below host.json file will create two unauthenticated endpoints. You can do this in azure portal by\u00a0<a title=\"https:\/\/learn.microsoft.com\/en-us\/azure\/logic-apps\/edit-app-settings-host-settings?tabs=azure-portal#manage-host-settings---hostjson\" href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/logic-apps\/edit-app-settings-host-settings?tabs=azure-portal#manage-host-settings---hostjson\" data-href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/logic-apps\/edit-app-settings-host-settings?tabs=azure-portal#manage-host-settings---hostjson\">going to kudu console and editing the host.json file<\/a>\u00a0located at C:\\home\\site\\wwwroot\\host.json.<\/p>\n<pre><code class=\"code-line language-json\" dir=\"auto\" data-line=\"170\"><span class=\"hljs-punctuation\">{<\/span> \r\n  <span class=\"hljs-attr\">\"version\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-string\">\"2.0\"<\/span><span class=\"hljs-punctuation\">,<\/span> \r\n  <span class=\"hljs-attr\">\"extensionBundle\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-punctuation\">{<\/span> \r\n    <span class=\"hljs-attr\">\"id\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-string\">\"Microsoft.Azure.Functions.ExtensionBundle.Workflows\"<\/span><span class=\"hljs-punctuation\">,<\/span> \r\n    <span class=\"hljs-attr\">\"version\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-string\">\"[1.*, 2.0.0)\"<\/span> \r\n  <span class=\"hljs-punctuation\">}<\/span><span class=\"hljs-punctuation\">,<\/span> \r\n  <span class=\"hljs-attr\">\"extensions\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-punctuation\">{<\/span> \r\n    <span class=\"hljs-attr\">\"http\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-punctuation\">{<\/span> \r\n      <span class=\"hljs-attr\">\"routePrefix\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-string\">\"\"<\/span> \r\n    <span class=\"hljs-punctuation\">}<\/span><span class=\"hljs-punctuation\">,<\/span> \r\n    <span class=\"hljs-attr\">\"workflow\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-punctuation\">{<\/span> \r\n      <span class=\"hljs-attr\">\"MetadataEndpoints\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-punctuation\">{<\/span> \r\n        <span class=\"hljs-attr\">\"plugin\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-punctuation\">{<\/span> \r\n          <span class=\"hljs-attr\">\"enable\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-literal\"><span class=\"hljs-keyword\">true<\/span><\/span><span class=\"hljs-punctuation\">,<\/span> \r\n          <span class=\"hljs-attr\">\"Authentication\"<\/span><span class=\"hljs-punctuation\">:<\/span><span class=\"hljs-punctuation\">{<\/span> \r\n              <span class=\"hljs-attr\">\"Type\"<\/span><span class=\"hljs-punctuation\">:<\/span><span class=\"hljs-string\">\"Anonymous\"<\/span> \r\n          <span class=\"hljs-punctuation\">}<\/span> \r\n        <span class=\"hljs-punctuation\">}<\/span><span class=\"hljs-punctuation\">,<\/span> \r\n        <span class=\"hljs-attr\">\"openapi\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-punctuation\">{<\/span> \r\n          <span class=\"hljs-attr\">\"enable\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-literal\"><span class=\"hljs-keyword\">true<\/span><\/span><span class=\"hljs-punctuation\">,<\/span> \r\n          <span class=\"hljs-attr\">\"Authentication\"<\/span><span class=\"hljs-punctuation\">:<\/span><span class=\"hljs-punctuation\">{<\/span> \r\n              <span class=\"hljs-attr\">\"Type\"<\/span><span class=\"hljs-punctuation\">:<\/span><span class=\"hljs-string\">\"Anonymous\"<\/span> \r\n          <span class=\"hljs-punctuation\">}<\/span> \r\n        <span class=\"hljs-punctuation\">}<\/span> \r\n      <span class=\"hljs-punctuation\">}<\/span><span class=\"hljs-punctuation\">,<\/span> \r\n      <span class=\"hljs-attr\">\"Settings\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-punctuation\">{<\/span> \r\n        <span class=\"hljs-attr\">\"Runtime.Triggers.RequestTriggerDefaultApiVersion\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-string\">\"2020-05-01-preview\"<\/span> \r\n      <span class=\"hljs-punctuation\">}<\/span> \r\n    <span class=\"hljs-punctuation\">}<\/span> \r\n  <span class=\"hljs-punctuation\">}<\/span> \r\n<span class=\"hljs-punctuation\">}<\/span> \r\n<\/code><\/pre>\n<h3 id=\"configure-your-application-for-easy-auth\" class=\"code-line\" dir=\"auto\" data-line=\"204\">Configure your application for Easy Auth<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"205\">You now want to secure your Logic App workflows so only authorized users can access them. You can do this by enabling Easy Auth on your Logic App. This will allow you to use the same authentication mechanism as your other Azure services, making it easier to manage your security policies.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"207\">For an in-depth walkthrough on setting up Easy Auth, refer to this great tutorial by Arjun Chiddarwar titled\u00a0<a title=\"https:\/\/techcommunity.microsoft.com\/t5\/azure-integration-services-blog\/trigger-workflows-in-standard-logic-apps-with-easy-auth\/ba-p\/3207378\" href=\"https:\/\/techcommunity.microsoft.com\/t5\/azure-integration-services-blog\/trigger-workflows-in-standard-logic-apps-with-easy-auth\/ba-p\/3207378\" data-href=\"https:\/\/techcommunity.microsoft.com\/t5\/azure-integration-services-blog\/trigger-workflows-in-standard-logic-apps-with-easy-auth\/ba-p\/3207378\">Trigger workflows in Standard logic apps with Easy Auth<\/a>.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"209\">For those already familiar with Easy Auth (and already have an Entra client app you want to use), this is the configuration you&#8217;ll want to post to Azure management.<\/p>\n<pre><code class=\"code-line\" dir=\"auto\" data-line=\"211\">PUT https:\/\/management.azure.com\/subscriptions\/80d4fe69-c95b-4dd2-a938-9250f1c8ab03\/resourceGroups\/&lt;resource_group&gt;\/providers\/Microsoft.Web\/sites\/&lt;app_name&gt;\/config\/authsettingsV2?api-version=2022-03-01 HTTP\/1.1\r\ncontent-type: application\/json\r\nAuthorization: Bearer &lt;ARM_Token&gt;\r\n\r\n{\r\n    \"properties\": {\r\n        \"platform\": {\r\n            \"enabled\": true,\r\n            \"runtimeVersion\": \"~1\"\r\n        },\r\n        \"globalValidation\": {\r\n            \"requireAuthentication\": true,\r\n            \"unauthenticatedClientAction\": \"AllowAnonymous\"\r\n        },\r\n        \"identityProviders\": {\r\n            \"azureActiveDirectory\": {\r\n                \"enabled\": true,\r\n                \"registration\": {\r\n                    \"openIdIssuer\": \"https:\/\/sts.windows.net\/[TENANT_ID]\/\",\r\n                    \"clientId\": \"[AAD_CLIENT_ID]\"\r\n                },\r\n                \"validation\": {\r\n                    \"jwtClaimChecks\": {},\r\n                    \"allowedAudiences\": [\r\n                        \"api:\/\/[AAD_CLIENT_ID]\"\r\n                    ],\r\n                    \"defaultAuthorizationPolicy\": {\r\n                        \"allowedPrincipals\": {\r\n                            \"identities\": [\r\n                                \"[OBJECT_ID_FOR_USER1]\",\r\n                                \"[OBJECT_ID_FOR_USER2]\",\r\n                                \"[OBJECT_ID_FOR_APP1]\"\r\n                            ]\r\n                        }\r\n                    }\r\n                }\r\n            },\r\n            \"facebook\": {\r\n                \"enabled\": false,\r\n                \"registration\": {},\r\n                \"login\": {}\r\n            },\r\n            \"gitHub\": {\r\n                \"enabled\": false,\r\n                \"registration\": {},\r\n                \"login\": {}\r\n            },\r\n            \"google\": {\r\n                \"enabled\": false,\r\n                \"registration\": {},\r\n                \"login\": {},\r\n                \"validation\": {}\r\n            },\r\n            \"twitter\": {\r\n                \"enabled\": false,\r\n                \"registration\": {}\r\n            },\r\n            \"legacyMicrosoftAccount\": {\r\n                \"enabled\": false,\r\n                \"registration\": {},\r\n                \"login\": {},\r\n                \"validation\": {}\r\n            },\r\n            \"apple\": {\r\n                \"enabled\": false,\r\n                \"registration\": {},\r\n                \"login\": {}\r\n            }\r\n        }\r\n    }\r\n}\r\n<\/code><\/pre>\n<h3 id=\"use-logic-apps-with-semantic-kernel-as-a-plugin\" class=\"code-line\" dir=\"auto\" data-line=\"285\">Use Logic Apps with Semantic Kernel as a plugin<\/h3>\n<p class=\"code-line\" dir=\"auto\" data-line=\"286\">Now that you have your Logic App secured and the metadata endpoints enabled, you&#8217;ve finished all the hard parts. You can now import your Logic App as a plugin into Semantic Kernel using the OpenAPI import method.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"288\">When you create your plugin, you&#8217;ll want to provide a custom HTTP client that can handle the authentication for your Logic App. This will allow you to use the plugin in your AI agents without needing to worry about the authentication.<\/p>\n<p class=\"code-line\" dir=\"auto\" data-line=\"290\">Below is an example in C# that leverages interactive auth to acquire a token and authenticate the user for the Logic App.<\/p>\n<pre><code class=\"code-line language-csharp\" dir=\"auto\" data-line=\"292\"><span class=\"hljs-built_in\">string<\/span> ClientId = <span class=\"hljs-string\">\"[AAD_CLIENT_ID]\"<\/span>;\r\n<span class=\"hljs-built_in\">string<\/span> TenantId = <span class=\"hljs-string\">\"[TENANT_ID]\"<\/span>;\r\n<span class=\"hljs-built_in\">string<\/span> Authority = <span class=\"hljs-string\">$\"https:\/\/login.microsoftonline.com\/<span class=\"hljs-subst\">{TenantId}<\/span>\"<\/span>;\r\n<span class=\"hljs-built_in\">string<\/span>[] Scopes = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-built_in\">string<\/span>[] { <span class=\"hljs-string\">\"api:\/\/[AAD_CIENT_ID]\/SKLogicApp\"<\/span> };\r\n\r\n<span class=\"hljs-keyword\">var<\/span> app = PublicClientApplicationBuilder.Create(ClientId)\r\n            .WithAuthority(Authority)\r\n            .WithDefaultRedirectUri() <span class=\"hljs-comment\">\/\/ Uses http:\/\/localhost for a console app<\/span>\r\n            .Build();\r\n\r\nAuthenticationResult authResult = <span class=\"hljs-literal\">null<\/span>;\r\n<span class=\"hljs-keyword\">try<\/span>\r\n{\r\n    authResult = <span class=\"hljs-keyword\">await<\/span> app.AcquireTokenInteractive(Scopes).ExecuteAsync();\r\n}\r\n<span class=\"hljs-keyword\">catch<\/span> (MsalException ex)\r\n{\r\n    Console.WriteLine(<span class=\"hljs-string\">\"An error occurred acquiring the token: \"<\/span> + ex.Message);\r\n}\r\n\r\n<span class=\"hljs-comment\">\/\/ Add the Logic App plugin to the kernel with the OpenAI import method<\/span>\r\nkernel.Plugins.Add(<span class=\"hljs-keyword\">await<\/span> kernel.CreatePluginFromOpenAIAsync(\r\n    pluginName: <span class=\"hljs-string\">\"[NAME_OF_PLUGIN]\"<\/span>,\r\n    uri: <span class=\"hljs-keyword\">new<\/span> Uri(<span class=\"hljs-string\">\"https:\/\/[LOGIC_APP_NAME].azurewebsites.net\/.well-known\/ai-plugin.json\"<\/span>),\r\n    executionParameters: <span class=\"hljs-keyword\">new<\/span> OpenAIFunctionExecutionParameters()\r\n    {\r\n        HttpClient = <span class=\"hljs-keyword\">new<\/span> HttpClient()\r\n        {\r\n            DefaultRequestHeaders =\r\n            {\r\n                Authorization = <span class=\"hljs-keyword\">new<\/span> AuthenticationHeaderValue(<span class=\"hljs-string\">\"Bearer\"<\/span>, authResult.AccessToken)\r\n            }\r\n        },\r\n    }\r\n));\r\n\r\n<span class=\"hljs-comment\">\/\/ ... or simply use the OpenAPI import method<\/span>\r\nkernel.Plugins.Add(<span class=\"hljs-keyword\">await<\/span> kernel.ImportPluginFromOpenApiAsync(\r\n    pluginName: <span class=\"hljs-string\">\"[NAME_OF_PLUGIN]\"<\/span>,\r\n    uri: <span class=\"hljs-keyword\">new<\/span> Uri(<span class=\"hljs-string\">\"https:\/\/[LOGIC_APP_NAME].azurewebsites.net\/swagger.json\"<\/span>),\r\n    executionParameters: <span class=\"hljs-keyword\">new<\/span> OpenApiFunctionExecutionParameters()\r\n    {\r\n        HttpClient = <span class=\"hljs-keyword\">new<\/span> HttpClient()\r\n        {\r\n            DefaultRequestHeaders =\r\n            {\r\n                Authorization = <span class=\"hljs-keyword\">new<\/span> AuthenticationHeaderValue(<span class=\"hljs-string\">\"Bearer\"<\/span>, authResult.AccessToken)\r\n            }\r\n        },\r\n    }\r\n));\r\n<\/code><\/pre>\n<h2 id=\"congratulations\" class=\"code-line\" dir=\"auto\" data-line=\"346\">Congratulations!<\/h2>\n<p class=\"code-line\" dir=\"auto\" data-line=\"347\">You&#8217;ve now successfully imported your Logic App as a plugin into Semantic Kernel. You can now use your Logic App in your AI agents to help automate your development processes, connect to legacy systems, integrate with third-party services, and more!<\/p>\n<p class=\"code-line code-active-line\" dir=\"auto\" data-line=\"349\">Let us know how you&#8217;re using Logic Apps with Semantic Kernel in the comments below. In the future we&#8217;ll only further deepen the connection between Semantic Kernel and Logic Apps, so we&#8217;d love to hear about your experiences and how we can help you build even more powerful AI agents.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At the heart of every company are custom APIs that are built to solve specific business problems. These APIs often use Logic Apps, which is a powerful way to build APIs\u00a0without writing code. With Logic Apps&#8217; over 1,400 enterprise connectors, you can connect to your enterprise systems, transform data, and automate processes to solve your [&hellip;]<\/p>\n","protected":false},"author":121401,"featured_media":2365,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[47,17,2,1],"tags":[],"class_list":["post-2721","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcement","category-announcements","category-samples","category-semantic-kernel"],"acf":[],"blog_post_summary":"<p>At the heart of every company are custom APIs that are built to solve specific business problems. These APIs often use Logic Apps, which is a powerful way to build APIs\u00a0without writing code. With Logic Apps&#8217; over 1,400 enterprise connectors, you can connect to your enterprise systems, transform data, and automate processes to solve your [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/2721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/users\/121401"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/comments?post=2721"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/2721\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media\/2365"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media?parent=2721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/categories?post=2721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/tags?post=2721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}