diff --git a/README.md b/README.md index d738a7655f..e6dd5161e3 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ Samples are designed to illustrate functionality you'll need to implement to bui |42|Scale out | Demonstrates how you can build your own state solution from the ground up that supports scaled out deployment with ETag based optimistic locking. |[.NET Core][cs#42] | |[Python][py#42]|[Java][java#42] |44|Basic custom prompts | Demonstrates how to implement your own _basic_ prompts to ask the user for information. |[.NET Core][cs#44]|[JavaScript][js#44]|[Python][py#44]|[Java][java#44] |47|Inspection middleware | Demonstrates how to use middleware to allow the Bot Framework Emulator to debug traffic into and out of the bot in addition to looking at the current state of the bot. | [.NET Core][cs#47] | [JavaScript][js#47] |[Python][py#47]|[Java][java#47] +|49| Proxy echo bot | Demonstrates how to configure the bot to use it behind a corporative proxy. | | [JavaScript][js#49] || |70|Styling webchat | This sample shows how to create a web page with custom Web Chat component.| | [ECMAScript 6][es#70] | ### Authentication samples @@ -77,7 +78,7 @@ Samples are designed to illustrate functionality you'll need to implement to bui |46|Teams authentication | Demonstrates how to use authentication for a bot running in Microsoft Teams. | [.NET Core](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-teams-authentication/csharp) | [JavaScript](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-conversation-sso-quickstart/js) |[Python](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-teams-authentication/python)|[Java](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-teams-authentication/java) |84|Certificate authentication | Demonstrates how to use Certificates to authenticate the bot | [.NET Core][cs#84] |[JavaScript][js#84] | | |85|Subject name/issuer authentication | Demonstrates how to use the subject name/issuer authentication in a bot | [.NET Core][cs#85] | [JavaScript][js#85] | | -|86|Federated Credentials authentication | Demonstrates how to use the FIC in a bot authentication | [.NET Core][cs#86] | | | +|86|Federated Credentials authentication | Demonstrates how to use the FIC in a bot authentication | [.NET Core][cs#86] | [JavaScript][js#86] | | ### Custom question answering samples @@ -97,7 +98,7 @@ Samples are designed to illustrate functionality you'll need to implement to bui |52|Messaging extensions - auth and config | A Messaging Extension that has a configuration page, accepts search requests and returns results after the user has signed in.|[.NET Core](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-search-auth-config/csharp)|[JavaScript](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-search-sso-config/nodejs) | | |53|Messaging extensions - action preview | Demonstrates how to create a Preview and Edit flow for a Messaging Extension.|[.NET Core](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-action-preview/csharp)|[JavaScript](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-action-preview/nodejs) |[Python](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-action-preview/python) |[Java](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-action-preview/java) |54|Task module | Demonstrates how to retrieve a Task Module, and values from cards in the Task Module, for a Messaging Extension.|[.NET Core](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-task-module/csharp)|[JavaScript](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-task-module/nodejs) |[Python](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-task-module/python) |[Java](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-task-module/java) -|55|Link unfurling | A Messaging Extension that performs link unfurling.|[.NET Core](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-link-unfurling/csharp))|[JavaScript](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-link-unfurling/nodejs) |[Python](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-link-unfurling/python) |[Java](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-link-unfurling/java) +|55|Link unfurling | A Messaging Extension that performs link unfurling.|[.NET Core](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-link-unfurling/csharp)|[JavaScript](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-link-unfurling/nodejs) |[Python](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-link-unfurling/python) |[Java](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/msgext-link-unfurling/java) |56|File upload | Demonstrates how to obtain file consent, and upload files to Teams from a bot. Also, how to receive a file sent to a bot.|[.NET Core](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-file-upload/csharp)|[JavaScript](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-file-upload/nodejs) |[Python](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-file-upload/python) |[Java](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-file-upload/java) |57|Conversation bot | Demonstrates various features of bots on Teams: message all members in a Team or Channel, @mention a user from a bot, update previously sent messages, etc. |[.NET Core](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-conversation/csharp)|[JavaScript](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-conversation/nodejs) |[Python](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-conversation/python) |[Java](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-conversation/java) |58|Start new thread in a channel | Demonstrates creating a new thread in a channel. |[.NET Core](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-initiate-thread-in-channel/csharp)|[JavaScript](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-initiate-thread-in-channel/nodejs) |[Python](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-initiate-thread-in-channel/python) |[Java](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-initiate-thread-in-channel/java) @@ -136,6 +137,7 @@ A [collection of **experimental** samples](./experimental) exist, intended to pr [cs#43]:samples/csharp_dotnetcore/43.complex-dialog [cs#44]:samples/csharp_dotnetcore/44.prompt-users-for-input [cs#45]:samples/csharp_dotnetcore/45.state-management +[cs#47]:samples/csharp_dotnetcore/47.inspection [cs#48]:samples/csharp_dotnetcore/48.customQABot-all-features [cs#60]:samples/csharp_dotnetcore/60.slack-adapter [cs#61]:samples/csharp_dotnetcore/61.facebook-adapter @@ -187,11 +189,13 @@ A [collection of **experimental** samples](./experimental) exist, intended to pr [js#45]:samples/javascript_nodejs/45.state-management [js#47]:samples/javascript_nodejs/47.inspection [js#48]:samples/javascript_nodejs/48.customQABot-all-features +[js#49]:samples/javascript_nodejs/49.echo-proxy-bot [js#80]:samples/javascript_nodejs/80.skills-simple-bot-to-bot [js#81]:samples/javascript_nodejs/81.skills-skilldialog [js#82]:samples/javascript_nodejs/82.skills-sso-cloudadapter [js#84]:samples/javascript_nodejs/84.bot-authentication-certificate [js#85]:samples/javascript_nodejs/85.bot-authentication-sni +[js#86]:samples/javascript_nodejs/86.bot-authentication-fic [py#1]:samples/python/01.console-echo [py#2]:samples/python/02.echo-bot diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/.env b/samples/javascript_nodejs/49.echo-proxy-bot/.env similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/.env rename to samples/javascript_nodejs/49.echo-proxy-bot/.env diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/.eslintrc.js b/samples/javascript_nodejs/49.echo-proxy-bot/.eslintrc.js similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/.eslintrc.js rename to samples/javascript_nodejs/49.echo-proxy-bot/.eslintrc.js diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/README.md b/samples/javascript_nodejs/49.echo-proxy-bot/README.md similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/README.md rename to samples/javascript_nodejs/49.echo-proxy-bot/README.md diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/bot.js b/samples/javascript_nodejs/49.echo-proxy-bot/bot.js similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/bot.js rename to samples/javascript_nodejs/49.echo-proxy-bot/bot.js diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentScripts/linux/.deployment b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentScripts/linux/.deployment similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentScripts/linux/.deployment rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentScripts/linux/.deployment diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentScripts/linux/deploy.sh b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentScripts/linux/deploy.sh similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentScripts/linux/deploy.sh rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentScripts/linux/deploy.sh diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentScripts/windows/.deployment b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentScripts/windows/.deployment similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentScripts/windows/.deployment rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentScripts/windows/.deployment diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentScripts/windows/deploy.cmd b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentScripts/windows/deploy.cmd similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentScripts/windows/deploy.cmd rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentScripts/windows/deploy.cmd diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/parameters-for-template-AzureBot-with-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/parameters-for-template-AzureBot-with-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/parameters-for-template-AzureBot-with-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/parameters-for-template-AzureBot-with-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/parameters-for-template-BotApp-with-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/parameters-for-template-BotApp-with-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/parameters-for-template-BotApp-with-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/parameters-for-template-BotApp-with-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/readme.md b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/readme.md similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/readme.md rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/readme.md diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/template-AzureBot-with-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/template-AzureBot-with-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/template-AzureBot-with-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/template-AzureBot-with-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/template-BotApp-with-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/template-BotApp-with-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/template-BotApp-with-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployUseExistResourceGroup/template-BotApp-with-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/parameters-for-template-AzureBot-new-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/parameters-for-template-AzureBot-new-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/parameters-for-template-AzureBot-new-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/parameters-for-template-AzureBot-new-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/parameters-for-template-BotApp-new-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/parameters-for-template-BotApp-new-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/parameters-for-template-BotApp-new-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/parameters-for-template-BotApp-new-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/readme.md b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/readme.md similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/readme.md rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/readme.md diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/template-AzureBot-new-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/template-AzureBot-new-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/template-AzureBot-new-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/template-AzureBot-new-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/template-BotApp-new-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/template-BotApp-new-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/template-BotApp-new-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/deployWithNewResourceGroup/template-BotApp-new-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/parameters-for-template-AzureBot-with-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/parameters-for-template-AzureBot-with-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/parameters-for-template-AzureBot-with-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/parameters-for-template-AzureBot-with-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/parameters-for-template-BotApp-with-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/parameters-for-template-BotApp-with-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/parameters-for-template-BotApp-with-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/parameters-for-template-BotApp-with-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/readme.md b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/readme.md similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/readme.md rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/readme.md diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/template-AzureBot-with-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/template-AzureBot-with-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/template-AzureBot-with-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/template-AzureBot-with-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/template-BotApp-with-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/template-BotApp-with-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/template-BotApp-with-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployUseExistResourceGroup/template-BotApp-with-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/parameters-for-template-AzureBot-new-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/parameters-for-template-AzureBot-new-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/parameters-for-template-AzureBot-new-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/parameters-for-template-AzureBot-new-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/parameters-for-template-BotApp-new-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/parameters-for-template-BotApp-new-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/parameters-for-template-BotApp-new-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/parameters-for-template-BotApp-new-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/readme.md b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/readme.md similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/readme.md rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/readme.md diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/template-AzureBot-new-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/template-AzureBot-new-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/template-AzureBot-new-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/template-AzureBot-new-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/template-BotApp-new-rg.json b/samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/template-BotApp-new-rg.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/template-BotApp-new-rg.json rename to samples/javascript_nodejs/49.echo-proxy-bot/deploymentTemplates/linux/deployWithNewResourceGroup/template-BotApp-new-rg.json diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/index.js b/samples/javascript_nodejs/49.echo-proxy-bot/index.js similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/index.js rename to samples/javascript_nodejs/49.echo-proxy-bot/index.js diff --git a/samples/javascript_nodejs/86.echo-proxy-bot/package.json b/samples/javascript_nodejs/49.echo-proxy-bot/package.json similarity index 100% rename from samples/javascript_nodejs/86.echo-proxy-bot/package.json rename to samples/javascript_nodejs/49.echo-proxy-bot/package.json diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/.env b/samples/javascript_nodejs/86.bot-authentication-fic/.env new file mode 100644 index 0000000000..205aa6078c --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/.env @@ -0,0 +1,4 @@ +MicrosoftAppType= +MicrosoftAppId= +MicrosoftAppClientId= +MicrosoftAppTenantId= diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/.eslintrc.js b/samples/javascript_nodejs/86.bot-authentication-fic/.eslintrc.js new file mode 100644 index 0000000000..43b3d45dd2 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/.eslintrc.js @@ -0,0 +1,15 @@ +/* eslint-disable */ +module.exports = { + "extends": "standard", + "rules": { + "semi": [2, "always"], + "indent": [2, 4], + "no-return-await": 0, + "space-before-function-paren": [2, { + "named": "never", + "anonymous": "never", + "asyncArrow": "always" + }], + "template-curly-spacing": [2, "always"] + } +}; \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/README.md b/samples/javascript_nodejs/86.bot-authentication-fic/README.md new file mode 100644 index 0000000000..ec612435e5 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/README.md @@ -0,0 +1,82 @@ +# Authentication Bot using Federation Identity Certificate (FIC) + +Bot Framework v4 bot authentication using Federation Identity Certificate (FIC). Currently, FIC feature is supported for Microsoft tenants only. + +This bot has been created using [Bot Framework](https://dev.botframework.com/), is shows how to use the bot authencation capabilities of Azure Bot Service. In this sample, we use federated identity certificate configuration to create the Bot Framework Authentication. + +## Prerequisites + +- [Node.js](https://nodejs.org) version 18 or higher + + ```bash + # determine node version + node --version + ``` + +- [Bot Framework SDK](https://github.com/microsoft/botbuilder-dotnet/releases) version 4.23.1 onwards + +## To try this sample + +- In a terminal, navigate to `samples/javascript_nodejs/86.bot-authentication-fic` + + ```bash + cd samples/javascript_nodejs/86.bot-authentication-fic + ``` + +- Install modules + + ```bash + npm install + ``` + +- Create an user assigned managed identity. + + - Record the client ID of the managed identity and add the same to .env file. + +- Create Azure App and Bot + + - Create App Registration + - This can be either Single or Multi tenant. + - Record the Application ID. + - Add the Federation Identity Certificate (FIC) to the App Registration. + - To create trust using the FIC, we need to link the managed identity to the App Registration. + - Click on the add credential under Federated Credential + - On the Add a credential page, select the Federated credential scenario as "Customer Managed Keys". + - Select the managed identity that you created in the previous step. + - Enter name for the credential and click on Add. + - Create an Azure Bot in the desired resource group. Use the App Registration from the previous step. + + - Add the User managed identity created in previous step to the Azure App Service under Configuration -> Identity -> User Assigned Managed Identity. + +- Set .env variables + + - MicrosoftAppType: {SingTenant | MultiTenant} + + - MicrosoftAppId: {appId} + + - MicrosoftAppTenantId: {tenantId} + + - MicrosoftAppClientId: {clientId of managed identity} + +- Start the bot + + ```bash + npm start + ``` + +## Deploy the bot to Azure + +To learn more about deploying a bot to Azure, see [Deploy your bot to Azure](https://aka.ms/azuredeployment) for a complete list of deployment instructions. + +## Further reading + +- [Bot Framework Documentation](https://docs.botframework.com) +- [Bot Basics](https://docs.microsoft.com/azure/bot-service/bot-builder-basics?view=azure-bot-service-4.0) +- [Activity processing](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-concept-activity-processing?view=azure-bot-service-4.0) +- [Azure Bot Service Introduction](https://docs.microsoft.com/azure/bot-service/bot-service-overview-introduction?view=azure-bot-service-4.0) +- [Azure Bot Service Documentation](https://docs.microsoft.com/azure/bot-service/?view=azure-bot-service-4.0) +- [.NET Core CLI tools](https://docs.microsoft.com/en-us/dotnet/core/tools/?tabs=netcore2x) +- [Azure CLI](https://docs.microsoft.com/cli/azure/?view=azure-cli-latest) +- [Azure Portal](https://portal.azure.com) +- [Language Understanding using LUIS](https://docs.microsoft.com/en-us/azure/cognitive-services/luis/) +- [Channels and Bot Connector Service](https://docs.microsoft.com/en-us/azure/bot-service/bot-concepts?view=azure-bot-service-4.0) diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/bot.js b/samples/javascript_nodejs/86.bot-authentication-fic/bot.js new file mode 100644 index 0000000000..f1a5a2428c --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/bot.js @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +const { ActivityHandler, MessageFactory } = require('botbuilder'); + +class EchoBot extends ActivityHandler { + constructor() { + super(); + // See https://aka.ms/about-bot-activity-message to learn more about the message and other activity types. + this.onMessage(async (context, next) => { + const replyText = `Echo: ${ context.activity.text }`; + const message = MessageFactory.text(replyText, replyText); + await context.sendActivity(message); + // By calling next() you ensure that the next BotHandler is run. + await next(); + }); + + this.onMembersAdded(async (context, next) => { + const membersAdded = context.activity.membersAdded; + const welcomeText = 'Hello and welcome to Echo Bot Using Federated Identity Credentials !!'; + for (let cnt = 0; cnt < membersAdded.length; ++cnt) { + if (membersAdded[cnt].id !== context.activity.recipient.id) { + await context.sendActivity(MessageFactory.text(welcomeText, welcomeText)); + } + } + // By calling next() you ensure that the next BotHandler is run. + await next(); + }); + } +} + +module.exports.EchoBot = EchoBot; diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentScripts/linux/.deployment b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentScripts/linux/.deployment new file mode 100644 index 0000000000..1047846624 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentScripts/linux/.deployment @@ -0,0 +1,2 @@ +[config] +command = ./deploy.sh \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentScripts/linux/deploy.sh b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentScripts/linux/deploy.sh new file mode 100644 index 0000000000..8c02d427cc --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentScripts/linux/deploy.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +# ---------------------- +# KUDU Deployment Script +# Version: 1.0.17 +# ---------------------- + +# Helpers +# ------- + +exitWithMessageOnError () { + if [ ! $? -eq 0 ]; then + echo "An error has occurred during web site deployment." + echo $1 + exit 1 + fi +} + +# Prerequisites +# ------------- + +# Verify node.js installed +hash node 2>/dev/null +exitWithMessageOnError "Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment." + +# Setup +# ----- + +SCRIPT_DIR="${BASH_SOURCE[0]%\\*}" +SCRIPT_DIR="${SCRIPT_DIR%/*}" +ARTIFACTS=$SCRIPT_DIR/../artifacts +KUDU_SYNC_CMD=${KUDU_SYNC_CMD//\"} + +if [[ ! -n "$DEPLOYMENT_SOURCE" ]]; then + DEPLOYMENT_SOURCE=$SCRIPT_DIR +fi + +if [[ ! -n "$NEXT_MANIFEST_PATH" ]]; then + NEXT_MANIFEST_PATH=$ARTIFACTS/manifest + + if [[ ! -n "$PREVIOUS_MANIFEST_PATH" ]]; then + PREVIOUS_MANIFEST_PATH=$NEXT_MANIFEST_PATH + fi +fi + +if [[ ! -n "$DEPLOYMENT_TARGET" ]]; then + DEPLOYMENT_TARGET=$ARTIFACTS/wwwroot +else + KUDU_SERVICE=true +fi + +if [[ ! -n "$KUDU_SYNC_CMD" ]]; then + # Install kudu sync + echo Installing Kudu Sync + npm install kudusync -g --silent + exitWithMessageOnError "npm failed" + + if [[ ! -n "$KUDU_SERVICE" ]]; then + # In case we are running locally this is the correct location of kuduSync + KUDU_SYNC_CMD=kuduSync + else + # In case we are running on kudu service this is the correct location of kuduSync + KUDU_SYNC_CMD=$APPDATA/npm/node_modules/kuduSync/bin/kuduSync + fi +fi + +# Node Helpers +# ------------ + +selectNodeVersion () { + NPM_CMD=npm + NODE_EXE=node +} + +################################################################################################################################## +# Deployment +# ---------- + +echo Handling node.js deployment. + +# 1. KuduSync +if [[ "$IN_PLACE_DEPLOYMENT" -ne "1" ]]; then + "$KUDU_SYNC_CMD" -v 50 -f "$DEPLOYMENT_SOURCE" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg;.deployment;deploy.sh" + exitWithMessageOnError "Kudu Sync failed" +fi + +# 2. Select node version +selectNodeVersion + +# 3. Install npm packages +if [ -e "$DEPLOYMENT_TARGET/package.json" ]; then + cd "$DEPLOYMENT_TARGET" + echo "Running $NPM_CMD install --production" + eval $NPM_CMD install --production + exitWithMessageOnError "npm failed" + cd - > /dev/null +fi + +################################################################################################################################## +echo "Finished successfully." \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentScripts/windows/.deployment b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentScripts/windows/.deployment new file mode 100644 index 0000000000..db5488a1df --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentScripts/windows/.deployment @@ -0,0 +1,2 @@ +[config] +command = deploy.cmd \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentScripts/windows/deploy.cmd b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentScripts/windows/deploy.cmd new file mode 100644 index 0000000000..7a40dcabf5 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentScripts/windows/deploy.cmd @@ -0,0 +1,133 @@ +@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off + +:: ---------------------- +:: KUDU Deployment Script +:: Version: 1.0.17 +:: ---------------------- + +:: Prerequisites +:: ------------- + +:: Verify node.js installed +where node 2>nul >nul +IF %ERRORLEVEL% NEQ 0 ( + echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment. + goto error +) + +:: Setup +:: ----- + +setlocal enabledelayedexpansion + +SET ARTIFACTS=%~dp0%..\artifacts + +IF NOT DEFINED DEPLOYMENT_SOURCE ( + SET DEPLOYMENT_SOURCE=%~dp0%. +) + +IF NOT DEFINED DEPLOYMENT_TARGET ( + SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot +) + +IF NOT DEFINED NEXT_MANIFEST_PATH ( + SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest + + IF NOT DEFINED PREVIOUS_MANIFEST_PATH ( + SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest + ) +) + +IF NOT DEFINED KUDU_SYNC_CMD ( + :: Install kudu sync + echo Installing Kudu Sync + call npm install kudusync -g --silent + IF !ERRORLEVEL! NEQ 0 goto error + + :: Locally just running "kuduSync" would also work + SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd +) +goto Deployment + +:: Utility Functions +:: ----------------- + +:SelectNodeVersion + +IF DEFINED KUDU_SELECT_NODE_VERSION_CMD ( + :: The following are done only on Windows Azure Websites environment + call %KUDU_SELECT_NODE_VERSION_CMD% "%DEPLOYMENT_SOURCE%" "%DEPLOYMENT_TARGET%" "%DEPLOYMENT_TEMP%" + IF !ERRORLEVEL! NEQ 0 goto error + + IF EXIST "%DEPLOYMENT_TEMP%\__nodeVersion.tmp" ( + SET /p NODE_EXE=<"%DEPLOYMENT_TEMP%\__nodeVersion.tmp" + IF !ERRORLEVEL! NEQ 0 goto error + ) + + IF EXIST "%DEPLOYMENT_TEMP%\__npmVersion.tmp" ( + SET /p NPM_JS_PATH=<"%DEPLOYMENT_TEMP%\__npmVersion.tmp" + IF !ERRORLEVEL! NEQ 0 goto error + ) + + IF NOT DEFINED NODE_EXE ( + SET NODE_EXE=node + ) + + SET NPM_CMD="!NODE_EXE!" "!NPM_JS_PATH!" +) ELSE ( + SET NPM_CMD=npm + SET NODE_EXE=node +) + +goto :EOF + +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: Deployment +:: ---------- + +:Deployment +echo Handling node.js deployment. + +:: 1. KuduSync +IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" ( + call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_SOURCE%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd" + IF !ERRORLEVEL! NEQ 0 goto error +) + +:: 2. Select node version +call :SelectNodeVersion + +:: 3. Install npm packages +IF EXIST "%DEPLOYMENT_TARGET%\package.json" ( + pushd "%DEPLOYMENT_TARGET%" + call :ExecuteCmd !NPM_CMD! install --production + IF !ERRORLEVEL! NEQ 0 goto error + popd +) + +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +goto end + +:: Execute command routine that will echo out when error +:ExecuteCmd +setlocal +set _CMD_=%* +call %_CMD_% +if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_% +exit /b %ERRORLEVEL% + +:error +endlocal +echo An error has occurred during web site deployment. +call :exitSetErrorLevel +call :exitFromFunction 2>nul + +:exitSetErrorLevel +exit /b 1 + +:exitFromFunction +() + +:end +endlocal +echo Finished successfully. diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/parameters-for-template-AzureBot-with-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/parameters-for-template-AzureBot-with-rg.json new file mode 100644 index 0000000000..c2c03ef307 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/parameters-for-template-AzureBot-with-rg.json @@ -0,0 +1,33 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "azureBotId": { + "value": "" + }, + "azureBotSku": { + "value": "S1" + }, + "azureBotRegion": { + "value": "global" + }, + "botEndpoint": { + "value": "" + }, + "appType": { + "value": "MultiTenant" + }, + "appId": { + "value": "" + }, + "UMSIName": { + "value": "" + }, + "UMSIResourceGroupName": { + "value": "" + }, + "tenantId": { + "value": "" + } + } +} \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/parameters-for-template-BotApp-with-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/parameters-for-template-BotApp-with-rg.json new file mode 100644 index 0000000000..c4b2909008 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/parameters-for-template-BotApp-with-rg.json @@ -0,0 +1,48 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "appServiceName": { + "value": "" + }, + "existingAppServicePlanName": { + "value": "" + }, + "existingAppServicePlanLocation": { + "value": "" + }, + "newAppServicePlanName": { + "value": "" + }, + "newAppServicePlanLocation": { + "value": "" + }, + "newAppServicePlanSku": { + "value": { + "name": "S1", + "tier": "Standard", + "size": "S1", + "family": "S", + "capacity": 1 + } + }, + "appType": { + "value": "MultiTenant" + }, + "appId": { + "value": "" + }, + "appSecret": { + "value": "" + }, + "UMSIName": { + "value": "" + }, + "UMSIResourceGroupName": { + "value": "" + }, + "tenantId": { + "value": "" + } + } +} \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/readme.md b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/readme.md new file mode 100644 index 0000000000..ba81e5b608 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/readme.md @@ -0,0 +1,38 @@ +# Usage +BotApp must be deployed prior to AzureBot. + +### Command line: +`az login`
+`az deployment group create --resource-group --template-file --parameters @` + +## Parameters for template-BotApp-with-rg.json: + +- **appServiceName**: (required) The Name of the Bot App Service. +- (Pick an existing App Service Plan or create a new App Service Plan.) + - **existingAppServicePlanName**: The name of the App Service Plan. + - **existingAppServicePlanLocation**: The location of the App Service Plan. + - **newAppServicePlanName**: The name of the App Service Plan. + - **newAppServicePlanLocation**: The location of the App Service Plan. + - **newAppServicePlanSku**: The SKU of the App Service Plan. Defaults to Standard values. +- **appType**: Type of Bot Authentication. set as MicrosoftAppType in the Web App's Application Settings. **Allowed values are: MultiTenant(default), SingleTenant, UserAssignedMSI.** +- **appId**: (required) Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings. +- **appSecret**: (required for MultiTenant and SingleTenant) Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings. +- **UMSIName**: (required for UserAssignedMSI) The User-Assigned Managed Identity Resource used for the Bot's Authentication. +- **UMSIResourceGroupName**: (required for UserAssignedMSI) The User-Assigned Managed Identity Resource Group used for the Bot's Authentication. +- **tenantId**: The Azure AD Tenant ID to use as part of the Bot's Authentication. Only used for SingleTenant and UserAssignedMSI app types. Defaults to Subscription Tenant ID. + +More info: https://docs.microsoft.com/en-us/azure/bot-service/tutorial-provision-a-bot?view=azure-bot-service-4.0&tabs=userassigned%2Cnewgroup#create-an-identity-resource + +## Parameters for template-AzureBot-with-rg.json: + +- **azureBotId**: (required) The globally unique and immutable bot ID. +- **azureBotSku**: The pricing tier of the Bot Service Registration. Allowed values are: F0, S1(default). +- **azureBotRegion**: Specifies the location of the new AzureBot. Allowed values are: global(default), westeurope. +- **botEndpoint**: Use to handle client messages, Such as `https://.azurewebsites.net/api/messages`. +- **appType**: Type of Bot Authentication. set as MicrosoftAppType in the Web App's Application Settings. Allowed values are: MultiTenant(default), SingleTenant, UserAssignedMSI. +- **appId**: (required) Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings. +- **UMSIName**: (required for UserAssignedMSI) The User-Assigned Managed Identity Resource used for the Bot's Authentication. +- **UMSIResourceGroupName**: (required for UserAssignedMSI) The User-Assigned Managed Identity Resource Group used for the Bot's Authentication. +- **tenantId**: The Azure AD Tenant ID to use as part of the Bot's Authentication. Only used for SingleTenant and UserAssignedMSI app types. Defaults to Subscription Tenant ID. + +More info: https://docs.microsoft.com/en-us/azure/bot-service/tutorial-provision-a-bot?view=azure-bot-service-4.0&tabs=userassigned%2Cnewgroup#create-an-identity-resource \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/template-AzureBot-with-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/template-AzureBot-with-rg.json new file mode 100644 index 0000000000..a8a960066f --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/template-AzureBot-with-rg.json @@ -0,0 +1,121 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "azureBotId": { + "type": "string", + "metadata": { + "description": "The globally unique and immutable bot ID." + } + }, + "azureBotSku": { + "type": "string", + "defaultValue": "S1", + "metadata": { + "description": "The pricing tier of the Bot Service Registration. Allowed values are: F0, S1(default)." + } + }, + "azureBotRegion": { + "type": "string", + "defaultValue": "global", + "metadata": { + "description": "Specifies the location of the new AzureBot. Allowed values are: global(default), westeurope." + } + }, + "botEndpoint": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "Use to handle client messages, Such as https://.azurewebsites.net/api/messages." + } + }, + "appType": { + "type": "string", + "defaultValue": "MultiTenant", + "allowedValues": [ + "MultiTenant", + "SingleTenant", + "UserAssignedMSI" + ], + "metadata": { + "description": "Type of Bot Authentication. set as MicrosoftAppType in the Web App's Application Settings. Allowed values are: MultiTenant, SingleTenant, UserAssignedMSI. Defaults to \"MultiTenant\"." + } + }, + "appId": { + "type": "string", + "metadata": { + "description": "Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings." + } + }, + "UMSIName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The User-Assigned Managed Identity Resource used for the Bot's Authentication." + } + }, + "UMSIResourceGroupName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The User-Assigned Managed Identity Resource Group used for the Bot's Authentication." + } + }, + "tenantId": { + "type": "string", + "defaultValue": "[subscription().tenantId]", + "metadata": { + "description": "The Azure AD Tenant ID to use as part of the Bot's Authentication. Only used for SingleTenant and UserAssignedMSI app types. Defaults to \"Subscription Tenant ID\"." + } + } + }, + "variables": { + "botEndpoint": "[if(empty(parameters('botEndpoint')), concat('https://', parameters('azureBotId'), '.azurewebsites.net/api/messages'), parameters('botEndpoint'))]", + "tenantId": "[if(empty(parameters('tenantId')), subscription().tenantId, parameters('tenantId'))]", + "msiResourceId": "[if(empty(parameters('UMSIName')), '', concat(subscription().id, '/resourceGroups/', parameters('UMSIResourceGroupName'), '/providers/', 'Microsoft.ManagedIdentity/userAssignedIdentities/', parameters('UMSIName')))]", + "appTypeDef": { + "MultiTenant": { + "tenantId": "", + "msiResourceId": "" + }, + "SingleTenant": { + "tenantId": "[variables('tenantId')]", + "msiResourceId": "" + }, + "UserAssignedMSI": { + "tenantId": "[variables('tenantId')]", + "msiResourceId": "[variables('msiResourceId')]" + } + }, + "appType": { + "tenantId": "[variables('appTypeDef')[parameters('appType')].tenantId]", + "msiResourceId": "[variables('appTypeDef')[parameters('appType')].msiResourceId]" + } + }, + "resources": [ + { + "apiVersion": "2021-05-01-preview", + "type": "Microsoft.BotService/botServices", + "name": "[parameters('azureBotId')]", + "location": "[parameters('azureBotRegion')]", + "kind": "azurebot", + "sku": { + "name": "[parameters('azureBotSku')]" + }, + "properties": { + "displayName": "[parameters('azureBotId')]", + "iconUrl": "https://docs.botframework.com/static/devportal/client/images/bot-framework-default.png", + "endpoint": "[variables('botEndpoint')]", + "msaAppId": "[parameters('appId')]", + "msaAppTenantId": "[variables('appType').tenantId]", + "msaAppMSIResourceId": "[variables('appType').msiResourceId]", + "msaAppType": "[parameters('appType')]", + "luisAppIds": [], + "schemaTransformationVersion": "1.3", + "isCmekEnabled": false, + "isIsolated": false + }, + "dependsOn": [] + } + ] +} \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/template-BotApp-with-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/template-BotApp-with-rg.json new file mode 100644 index 0000000000..93441894af --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployUseExistResourceGroup/template-BotApp-with-rg.json @@ -0,0 +1,191 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "appServiceName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The globally unique name of the Web App." + } + }, + "existingAppServicePlanName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "Name of the existing App Service Plan used to create the Web App for the bot." + } + }, + "existingAppServicePlanLocation": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The location of the App Service Plan." + } + }, + "newAppServicePlanName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The name of the new App Service Plan." + } + }, + "newAppServicePlanLocation": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The location of the App Service Plan." + } + }, + "newAppServicePlanSku": { + "type": "object", + "defaultValue": { + "name": "S1", + "tier": "Standard", + "size": "S1", + "family": "S", + "capacity": 1 + }, + "metadata": { + "description": "The SKU of the App Service Plan. Defaults to Standard values." + } + }, + "appType": { + "type": "string", + "defaultValue": "MultiTenant", + "allowedValues": [ + "MultiTenant", + "SingleTenant", + "UserAssignedMSI" + ], + "metadata": { + "description": "Type of Bot Authentication. set as MicrosoftAppType in the Web App's Application Settings. Allowed values are: MultiTenant, SingleTenant, UserAssignedMSI. Defaults to \"MultiTenant\"." + } + }, + "appId": { + "type": "string", + "metadata": { + "description": "Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings." + } + }, + "appSecret": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings. Required for MultiTenant and SingleTenant app types. Defaults to \"\"." + } + }, + "UMSIName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The User-Assigned Managed Identity Resource used for the Bot's Authentication. Defaults to \"\"." + } + }, + "UMSIResourceGroupName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The User-Assigned Managed Identity Resource Group used for the Bot's Authentication. Defaults to \"\"." + } + }, + "tenantId": { + "type": "string", + "defaultValue": "[subscription().tenantId]", + "metadata": { + "description": "The Azure AD Tenant ID to use as part of the Bot's Authentication. Only used for SingleTenant and UserAssignedMSI app types. Defaults to \"Subscription Tenant ID\"." + } + } + }, + "variables": { + "tenantId": "[if(empty(parameters('tenantId')), subscription().tenantId, parameters('tenantId'))]", + "useExistingServicePlan": "[not(empty(parameters('existingAppServicePlanName')))]", + "servicePlanName": "[if(variables('useExistingServicePlan'), parameters('existingAppServicePlanName'), parameters('newAppServicePlanName'))]", + "servicePlanLocation": "[if(variables('useExistingServicePlan'), parameters('existingAppServicePlanLocation'), parameters('newAppServicePlanLocation'))]", + "msiResourceId": "[if(empty(parameters('UMSIName')), '', concat(subscription().id, '/resourceGroups/', parameters('UMSIResourceGroupName'), '/providers/', 'Microsoft.ManagedIdentity/userAssignedIdentities/', parameters('UMSIName')))]", + "appTypeDef": { + "MultiTenant": { + "tenantId": "", + "identity": { "type": "None" } + }, + "SingleTenant": { + "tenantId": "[variables('tenantId')]", + "identity": { "type": "None" } + }, + "UserAssignedMSI": { + "tenantId": "[variables('tenantId')]", + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "[variables('msiResourceId')]": {} + } + } + } + }, + "appType": { + "tenantId": "[variables('appTypeDef')[parameters('appType')].tenantId]", + "identity": "[variables('appTypeDef')[parameters('appType')].identity]" + } + }, + "resources": [ + { + "comments": "Create a new App Service Plan if no existing App Service Plan name was passed in.", + "type": "Microsoft.Web/serverfarms", + "condition": "[not(variables('useExistingServicePlan'))]", + "name": "[variables('servicePlanName')]", + "apiVersion": "2018-02-01", + "location": "[parameters('newAppServicePlanLocation')]", + "sku": "[parameters('newAppServicePlanSku')]", + "properties": { + "name": "[variables('servicePlanName')]" + } + }, + { + "comments": "Create a Web App using an App Service Plan", + "type": "Microsoft.Web/sites", + "apiVersion": "2015-08-01", + "location": "[variables('servicePlanLocation')]", + "kind": "app", + "dependsOn": [ + "[resourceId('Microsoft.Web/serverfarms', variables('servicePlanName'))]" + ], + "name": "[parameters('appServiceName')]", + "identity": "[variables('appType').identity]", + "properties": { + "name": "[parameters('appServiceName')]", + "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('servicePlanName'))]", + "siteConfig": { + "appSettings": [ + { + "name": "WEBSITE_NODE_DEFAULT_VERSION", + "value": "~20" + }, + { + "name": "MicrosoftAppType", + "value": "[parameters('appType')]" + }, + { + "name": "MicrosoftAppId", + "value": "[parameters('appId')]" + }, + { + "name": "MicrosoftAppPassword", + "value": "[parameters('appSecret')]" + }, + { + "name": "MicrosoftAppTenantId", + "value": "[variables('appType').tenantId]" + } + ], + "cors": { + "allowedOrigins": [ + "https://botservice.hosting.portal.azure.net", + "https://hosting.onecloud.azure-test.net/" + ] + }, + "webSocketsEnabled": true + } + } + } + ] +} diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/parameters-for-template-AzureBot-new-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/parameters-for-template-AzureBot-new-rg.json new file mode 100644 index 0000000000..44f169e4d5 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/parameters-for-template-AzureBot-new-rg.json @@ -0,0 +1,39 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "groupName": { + "value": "" + }, + "groupLocation": { + "value": "" + }, + "azureBotId": { + "value": "" + }, + "azureBotSku": { + "value": "S1" + }, + "azureBotRegion": { + "value": "global" + }, + "botEndpoint": { + "value": "" + }, + "appType": { + "value": "MultiTenant" + }, + "appId": { + "value": "" + }, + "UMSIName": { + "value": "" + }, + "UMSIResourceGroupName": { + "value": "" + }, + "tenantId": { + "value": "" + } + } +} \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/parameters-for-template-BotApp-new-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/parameters-for-template-BotApp-new-rg.json new file mode 100644 index 0000000000..8abb03d597 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/parameters-for-template-BotApp-new-rg.json @@ -0,0 +1,48 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "groupName": { + "value": "" + }, + "groupLocation": { + "value": "" + }, + "appServiceName": { + "value": "" + }, + "appServicePlanName": { + "value": "" + }, + "appServicePlanLocation": { + "value": "" + }, + "appServicePlanSku": { + "value": { + "name": "S1", + "tier": "Standard", + "size": "S1", + "family": "S", + "capacity": 1 + } + }, + "appType": { + "value": "MultiTenant" + }, + "appId": { + "value": "" + }, + "appSecret": { + "value": "" + }, + "UMSIName": { + "value": "" + }, + "UMSIResourceGroupName": { + "value": "" + }, + "tenantId": { + "value": "" + } + } +} \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/readme.md b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/readme.md new file mode 100644 index 0000000000..2f2571d06d --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/readme.md @@ -0,0 +1,45 @@ +# Usage +BotApp must be deployed prior to AzureBot. + +### Command line: +`az login`
+`az deployment sub create --template-file --location --parameters @` + +## Parameters for template-BotApp-new-rg.json: + +- **groupName**: (required) The name of the new Resource Group. +- **groupLocation**: (required) The location of the new Resource Group. + +- **appServiceName**: (required) The location of the App Service Plan. +- **appServicePlanName**: (required) The name of the App Service Plan. +- **appServicePlanLocation**: The location of the App Service Plan. Defaults to use groupLocation. +- **appServicePlanSku**: The SKU of the App Service Plan. Defaults to Standard values. + +- **appType**: Type of Bot Authentication. set as MicrosoftAppType in the Web App's Application Settings. Allowed values are: MultiTenant(default), SingleTenant, UserAssignedMSI. +- **appId**: (required) Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings. +- **appSecret**: (required for MultiTenant and SingleTenant) Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings. +- **UMSIName**: (required for UserAssignedMSI) The User-Assigned Managed Identity Resource used for the Bot's Authentication. +- **UMSIResourceGroupName**:(required for UserAssignedMSI) The User-Assigned Managed Identity Resource Group used for the Bot's Authentication. +- **tenantId**: The Azure AD Tenant ID to use as part of the Bot's Authentication. Only used for SingleTenant and UserAssignedMSI app types. Defaults to . + +More info: https://docs.microsoft.com/en-us/azure/bot-service/tutorial-provision-a-bot?view=azure-bot-service-4.0&tabs=userassigned%2Cnewgroup#create-an-identity-resource + + + +## Parameters for template-AzureBot-new-rg.json: + +- **groupName**: (required) The name of the new Resource Group. +- **groupLocation**: (required) The location of the new Resource Group. + +- **azureBotId**: (required) The globally unique and immutable bot ID. Also used to configure the displayName of the bot, which is mutable. +- **azureBotSku**: The pricing tier of the Bot Service Registration. Allowed values are: F0, S1(default). +- **azureBotRegion**: Specifies the location of the new AzureBot. Allowed values are: global(default), westeurope. +- **botEndpoint**: Use to handle client messages, Such as `https://.azurewebsites.net/api/messages`. + +- **appType**: Type of Bot Authentication. set as MicrosoftAppType in the Web App's Application Settings. Allowed values are: MultiTenant(default), SingleTenant, UserAssignedMSI. +- **appId**: (required) Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings. +- **UMSIName**: (required for UserAssignedMSI) The User-Assigned Managed Identity Resource used for the Bot's Authentication. +- **UMSIResourceGroupName**: (required for UserAssignedMSI) The User-Assigned Managed Identity Resource Group used for the Bot's Authentication. +- **tenantId**: The Azure AD Tenant ID to use as part of the Bot's Authentication. Only used for SingleTenant and UserAssignedMSI app types. Defaults to Subscription Tenant ID. + +More info: https://docs.microsoft.com/en-us/azure/bot-service/tutorial-provision-a-bot?view=azure-bot-service-4.0&tabs=userassigned%2Cnewgroup#create-an-identity-resource \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/template-AzureBot-new-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/template-AzureBot-new-rg.json new file mode 100644 index 0000000000..ae073b7939 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/template-AzureBot-new-rg.json @@ -0,0 +1,160 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "groupName": { + "type": "string", + "metadata": { + "description": "Specifies the name of the Resource Group." + } + }, + "groupLocation": { + "type": "string", + "metadata": { + "description": "Specifies the location of the Resource Group." + } + }, + "azureBotId": { + "type": "string", + "metadata": { + "description": "The globally unique and immutable bot ID." + } + }, + "azureBotSku": { + "type": "string", + "defaultValue": "S1", + "metadata": { + "description": "The pricing tier of the Bot Service Registration. Acceptable values are F0 and S1." + } + }, + "azureBotRegion": { + "type": "string", + "defaultValue": "global", + "metadata": { + "description": "" + } + }, + "botEndpoint": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "Use to handle client messages, Such as https://.azurewebsites.net/api/messages." + } + }, + "appType": { + "type": "string", + "defaultValue": "MultiTenant", + "allowedValues": [ + "MultiTenant", + "SingleTenant", + "UserAssignedMSI" + ], + "metadata": { + "description": "Type of Bot Authentication. set as MicrosoftAppType in the Web App's Application Settings. Allowed values are: MultiTenant, SingleTenant, UserAssignedMSI. Defaults to \"MultiTenant\"." + } + }, + "appId": { + "type": "string", + "metadata": { + "description": "Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings." + } + }, + "tenantId": { + "type": "string", + "defaultValue": "[subscription().tenantId]", + "metadata": { + "description": "The Azure AD Tenant ID to use as part of the Bot's Authentication. Only used for SingleTenant and UserAssignedMSI app types. Defaults to \"Subscription Tenant ID\"." + } + }, + "UMSIName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The User-Assigned Managed Identity Resource used for the Bot's Authentication." + } + }, + "UMSIResourceGroupName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The User-Assigned Managed Identity Resource Group used for the Bot's Authentication." + } + } + }, + "variables": { + "botEndpoint": "[if(empty(parameters('botEndpoint')), concat('https://', parameters('azureBotId'), '.azurewebsites.net/api/messages'), parameters('botEndpoint'))]", + "tenantId": "[if(empty(parameters('tenantId')), subscription().tenantId, parameters('tenantId'))]", + "msiResourceId": "[if(empty(parameters('UMSIName')), '', concat(subscription().id, '/resourceGroups/', parameters('UMSIResourceGroupName'), '/providers/', 'Microsoft.ManagedIdentity/userAssignedIdentities/', parameters('UMSIName')))]", + "appTypeDef": { + "MultiTenant": { + "tenantId": "", + "msiResourceId": "" + }, + "SingleTenant": { + "tenantId": "[variables('tenantId')]", + "msiResourceId": "" + }, + "UserAssignedMSI": { + "tenantId": "[variables('tenantId')]", + "msiResourceId": "[variables('msiResourceId')]" + } + }, + "appType": { + "tenantId": "[variables('appTypeDef')[parameters('appType')].tenantId]", + "msiResourceId": "[variables('appTypeDef')[parameters('appType')].msiResourceId]" + } + }, + "resources": [ + { + "name": "[parameters('groupName')]", + "type": "Microsoft.Resources/resourceGroups", + "apiVersion": "2018-05-01", + "location": "[parameters('groupLocation')]", + "properties": {} + }, + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2018-05-01", + "name": "storageDeployment", + "resourceGroup": "[parameters('groupName')]", + "dependsOn": [ + "[resourceId('Microsoft.Resources/resourceGroups/', parameters('groupName'))]" + ], + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": {}, + "variables": {}, + "resources": [ + { + "apiVersion": "2021-03-01", + "type": "Microsoft.BotService/botServices", + "name": "[parameters('azureBotId')]", + "location": "[parameters('azureBotRegion')]", + "kind": "azurebot", + "sku": { + "name": "[parameters('azureBotSku')]" + }, + "properties": { + "name": "[parameters('azureBotId')]", + "displayName": "[parameters('azureBotId')]", + "iconUrl": "https://docs.botframework.com/static/devportal/client/images/bot-framework-default.png", + "endpoint": "[variables('botEndpoint')]", + "msaAppId": "[parameters('appId')]", + "msaAppTenantId": "[variables('appType').tenantId]", + "msaAppMSIResourceId": "[variables('appType').msiResourceId]", + "msaAppType": "[parameters('appType')]", + "luisAppIds": [], + "schemaTransformationVersion": "1.3", + "isCmekEnabled": false, + "isIsolated": false + } + } + ] + } + } + } + ] +} \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/template-BotApp-new-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/template-BotApp-new-rg.json new file mode 100644 index 0000000000..c10d46b3cf --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/deployWithNewResourceGroup/template-BotApp-new-rg.json @@ -0,0 +1,213 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "groupName": { + "type": "string", + "metadata": { + "description": "Specifies the name of the Resource Group." + } + }, + "groupLocation": { + "type": "string", + "metadata": { + "description": "Specifies the location of the Resource Group." + } + }, + "appServiceName": { + "type": "string", + "metadata": { + "description": "The globally unique name of the Web App." + } + }, + "appServicePlanName": { + "type": "string", + "metadata": { + "description": "The name of the App Service Plan." + } + }, + "appServicePlanLocation": { + "type": "string", + "metadata": { + "description": "The location of the App Service Plan." + } + }, + "appServicePlanSku": { + "type": "object", + "defaultValue": { + "name": "S1", + "tier": "Standard", + "size": "S1", + "family": "S", + "capacity": 1 + }, + "metadata": { + "description": "The SKU of the App Service Plan. Defaults to Standard values." + } + }, + "tenantId": { + "type": "string", + "defaultValue": "[subscription().tenantId]", + "metadata": { + "description": "The Azure AD Tenant ID to use as part of the Bot's Authentication. Only used for SingleTenant and UserAssignedMSI app types. Defaults to \"Subscription Tenant ID\"." + } + }, + "appType": { + "type": "string", + "defaultValue": "MultiTenant", + "allowedValues": [ + "MultiTenant", + "SingleTenant", + "UserAssignedMSI" + ], + "metadata": { + "description": "Type of Bot Authentication. set as MicrosoftAppType in the Web App's Application Settings. Allowed values are: MultiTenant, SingleTenant, UserAssignedMSI. Defaults to \"MultiTenant\"." + } + }, + "appId": { + "type": "string", + "metadata": { + "description": "Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings." + } + }, + "appSecret": { + "type": "string", + "metadata": { + "description": "Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings. Required for MultiTenant and SingleTenant app types." + } + }, + "UMSIName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The User-Assigned Managed Identity Resource used for the Bot's Authentication." + } + }, + "UMSIResourceGroupName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The User-Assigned Managed Identity Resource Group used for the Bot's Authentication." + } + } + }, + "variables": { + "tenantId": "[if(empty(parameters('tenantId')), subscription().tenantId, parameters('tenantId'))]", + "appServicePlanName": "[parameters('appServicePlanName')]", + "resourcesLocation": "[if(empty(parameters('appServicePlanLocation')), parameters('groupLocation'), parameters('appServicePlanLocation'))]", + "appServiceName": "[parameters('appServiceName')]", + "resourceGroupId": "[concat(subscription().id, '/resourceGroups/', parameters('groupName'))]", + "msiResourceId": "[if(empty(parameters('UMSIName')), '', concat(subscription().id, '/resourceGroups/', parameters('UMSIResourceGroupName'), '/providers/', 'Microsoft.ManagedIdentity/userAssignedIdentities/', parameters('UMSIName')))]", + "appTypeDef": { + "MultiTenant": { + "tenantId": "", + "identity": { "type": "None" } + }, + "SingleTenant": { + "tenantId": "[variables('tenantId')]", + "identity": { "type": "None" } + }, + "UserAssignedMSI": { + "tenantId": "[variables('tenantId')]", + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "[variables('msiResourceId')]": {} + } + } + } + }, + "appType": { + "tenantId": "[variables('appTypeDef')[parameters('appType')].tenantId]", + "identity": "[variables('appTypeDef')[parameters('appType')].identity]" + } + }, + "resources": [ + { + "name": "[parameters('groupName')]", + "type": "Microsoft.Resources/resourceGroups", + "apiVersion": "2018-05-01", + "location": "[parameters('groupLocation')]", + "properties": {} + }, + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2018-05-01", + "name": "storageDeployment", + "resourceGroup": "[parameters('groupName')]", + "dependsOn": [ + "[resourceId('Microsoft.Resources/resourceGroups/', parameters('groupName'))]" + ], + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": {}, + "variables": {}, + "resources": [ + { + "comments": "Create a new App Service Plan", + "type": "Microsoft.Web/serverfarms", + "name": "[variables('appServicePlanName')]", + "apiVersion": "2018-02-01", + "location": "[variables('resourcesLocation')]", + "sku": "[parameters('appServicePlanSku')]", + "properties": { + "name": "[variables('appServicePlanName')]" + } + }, + { + "comments": "Create a Web App using the new App Service Plan", + "type": "Microsoft.Web/sites", + "apiVersion": "2015-08-01", + "location": "[variables('resourcesLocation')]", + "kind": "app", + "dependsOn": [ + "[concat(variables('resourceGroupId'), '/providers/Microsoft.Web/serverfarms/', variables('appServicePlanName'))]" + ], + "name": "[variables('appServiceName')]", + "identity": "[variables('appType').identity]", + "properties": { + "name": "[variables('appServiceName')]", + "serverFarmId": "[variables('appServicePlanName')]", + "siteConfig": { + "appSettings": [ + { + "name": "WEBSITE_NODE_DEFAULT_VERSION", + "value": "~20" + }, + { + "name": "MicrosoftAppType", + "value": "[parameters('appType')]" + }, + { + "name": "MicrosoftAppId", + "value": "[parameters('appId')]" + }, + { + "name": "MicrosoftAppPassword", + "value": "[parameters('appSecret')]" + }, + { + "name": "MicrosoftAppTenantId", + "value": "[variables('appType').tenantId]" + } + ], + "cors": { + "allowedOrigins": [ + "https://botservice.hosting.portal.azure.net", + "https://hosting.onecloud.azure-test.net/" + ] + }, + "webSocketsEnabled": true + } + } + } + ], + "outputs": {} + } + } + } + ] +} diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/parameters-for-template-AzureBot-with-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/parameters-for-template-AzureBot-with-rg.json new file mode 100644 index 0000000000..cc1800c0db --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/parameters-for-template-AzureBot-with-rg.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "azureBotId": { + "value": "" + }, + "azureBotSku": { + "value": "S1" + }, + "azureBotRegion": { + "value": "global" + }, + "botEndpoint": { + "value": "" + }, + "appId": { + "value": "" + } + } +} \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/parameters-for-template-BotApp-with-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/parameters-for-template-BotApp-with-rg.json new file mode 100644 index 0000000000..c1f341b084 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/parameters-for-template-BotApp-with-rg.json @@ -0,0 +1,42 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "appServiceName": { + "value": "" + }, + "existingAppServicePlanName": { + "value": "" + }, + "existingAppServicePlanLocation": { + "value": "" + }, + "newAppServicePlanName": { + "value": "" + }, + "newAppServicePlanLocation": { + "value": "West US" + }, + "newAppServicePlanSku": { + "value": { + "name": "S1", + "tier": "Standard", + "size": "S1", + "family": "S", + "capacity": 1 + } + }, + "linuxFxVersion": { + "value": "" + }, + "appId": { + "value": "" + }, + "appSecret": { + "value": "" + }, + "appType": { + "value": "" + } + } +} \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/readme.md b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/readme.md new file mode 100644 index 0000000000..93086e1f57 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/readme.md @@ -0,0 +1,26 @@ +# Usage +BotApp must be deployed prior to AzureBot. + +### Command line: +`az login`
+`az deployment group create --resource-group --template-file --parameters @` + +## Parameters for template-BotApp-with-rg.json: + +- **appServiceName**: (required) The Name of the Bot App Service. +- (Pick an existing App Service Plan or create a new App Service Plan.) + - **existingAppServicePlanName**: The name of the App Service Plan. + - **existingAppServicePlanLocation**: The location of the App Service Plan. + - **newAppServicePlanName**: The name of the App Service Plan. + - **newAppServicePlanLocation**: The location of the App Service Plan. + - **newAppServicePlanSku**: The SKU of the App Service Plan. Defaults to Standard values. +- **appId**: (required) Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings. +- **appSecret**: (required for MultiTenant and SingleTenant) Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings. + +## Parameters for template-AzureBot-with-rg.json: + +- **azureBotId**: (required) The globally unique and immutable bot ID. +- **azureBotSku**: The pricing tier of the Bot Service Registration. Allowed values are: F0, S1(default). +- **azureBotRegion**: Specifies the location of the new AzureBot. Allowed values are: global(default), westeurope. +- **botEndpoint**: Use to handle client messages, Such as `https://.azurewebsites.net/api/messages`. +- **appId**: (required) Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings. \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/template-AzureBot-with-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/template-AzureBot-with-rg.json new file mode 100644 index 0000000000..60c9c1bb6c --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/template-AzureBot-with-rg.json @@ -0,0 +1,65 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "azureBotId": { + "type": "string", + "metadata": { + "description": "The globally unique and immutable bot ID." + } + }, + "azureBotSku": { + "type": "string", + "defaultValue": "S1", + "metadata": { + "description": "The pricing tier of the Bot Service Registration. Allowed values are: F0, S1(default)." + } + }, + "azureBotRegion": { + "type": "string", + "defaultValue": "global", + "metadata": { + "description": "Specifies the location of the new AzureBot. Allowed values are: global(default), westeurope." + } + }, + "botEndpoint": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "Use to handle client messages, Such as https://.azurewebsites.net/api/messages." + } + }, + "appId": { + "type": "string", + "metadata": { + "description": "Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings." + } + } + }, + "variables": { + "botEndpoint": "[if(empty(parameters('botEndpoint')), concat('https://', parameters('azureBotId'), '.azurewebsites.net/api/messages'), parameters('botEndpoint'))]" + }, + "resources": [ + { + "apiVersion": "2021-05-01-preview", + "type": "Microsoft.BotService/botServices", + "name": "[parameters('azureBotId')]", + "location": "[parameters('azureBotRegion')]", + "kind": "azurebot", + "sku": { + "name": "[parameters('azureBotSku')]" + }, + "properties": { + "name": "[parameters('azureBotId')]", + "displayName": "[parameters('azureBotId')]", + "iconUrl": "https://docs.botframework.com/static/devportal/client/images/bot-framework-default.png", + "endpoint": "[variables('botEndpoint')]", + "msaAppId": "[parameters('appId')]", + "luisAppIds": [], + "schemaTransformationVersion": "1.3", + "isCmekEnabled": false, + "isIsolated": false + } + } + ] +} \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/template-BotApp-with-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/template-BotApp-with-rg.json new file mode 100644 index 0000000000..db8f219d47 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployUseExistResourceGroup/template-BotApp-with-rg.json @@ -0,0 +1,221 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "appServiceName": { + "type": "string", + "metadata": { + "description": "The globally unique name of the Web App." + } + }, + "existingAppServicePlanName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "Name of the existing App Service Plan used to create the Web App for the bot." + } + }, + "existingAppServicePlanLocation": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The location of the App Service Plan." + } + }, + "newAppServicePlanName": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The name of the new App Service Plan." + } + }, + "newAppServicePlanLocation": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The location of the App Service Plan." + } + }, + "newAppServicePlanSku": { + "type": "object", + "defaultValue": { + "name": "S1", + "tier": "Standard", + "size": "S1", + "family": "S", + "capacity": 1 + }, + "metadata": { + "description": "The SKU of the App Service Plan. Defaults to Standard values." + } + }, + "linuxFxVersion": { + "type": "string", + "defaultValue": "NODE|20-LTS" + }, + "appId": { + "type": "string", + "metadata": { + "description": "Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings." + } + }, + "appSecret": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings. Required for MultiTenant and SingleTenant app types. Defaults to \"\"." + } + }, + "appType": { + "defaultValue": "MultiTenant", + "type": "string", + "allowedValues": [ + "MultiTenant", + "SingleTenant", + "UserAssignedMSI" + ] + } + }, + "variables": { + "useExistingServicePlan": "[not(empty(parameters('existingAppServicePlanName')))]", + "servicePlanName": "[if(variables('useExistingServicePlan'), parameters('existingAppServicePlanName'), parameters('newAppServicePlanName'))]", + "servicePlanLocation": "[if(variables('useExistingServicePlan'), parameters('existingAppServicePlanLocation'), parameters('newAppServicePlanLocation'))]" + }, + "resources": [ + { + "comments": "Create a new App Service Plan if no existing App Service Plan name was passed in.", + "type": "Microsoft.Web/serverfarms", + "condition": "[not(variables('useExistingServicePlan'))]", + "name": "[variables('servicePlanName')]", + "apiVersion": "2018-02-01", + "location": "[parameters('newAppServicePlanLocation')]", + "sku": "[parameters('newAppServicePlanSku')]", + "kind": "linux", + "properties": { + "name": "[variables('servicePlanName')]", + "perSiteScaling": false, + "reserved": true, + "targetWorkerCount": 0, + "targetWorkerSizeId": 0 + } + }, + { + "comments": "Create a Web App using an App Service Plan", + "type": "Microsoft.Web/sites", + "apiVersion": "2015-08-01", + "name": "[parameters('appServiceName')]", + "location": "[variables('servicePlanLocation')]", + "kind": "app,linux", + "dependsOn": [ + "[resourceId('Microsoft.Web/serverfarms', variables('servicePlanName'))]" + ], + "properties": { + "enabled": true, + "hostNameSslStates": [ + { + "name": "[concat(parameters('appServiceName'), '.azurewebsites.net')]", + "sslState": "Disabled", + "hostType": "Standard" + }, + { + "name": "[concat(parameters('appServiceName'), '.scm.azurewebsites.net')]", + "sslState": "Disabled", + "hostType": "Repository" + } + ], + "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('servicePlanName'))]", + "reserved": true, + "scmSiteAlsoStopped": false, + "clientAffinityEnabled": false, + "clientCertEnabled": false, + "hostNamesDisabled": false, + "containerSize": 0, + "dailyMemoryTimeQuota": 0, + "httpsOnly": false, + "siteConfig": { + "linuxFxVersion": "[parameters('linuxFxVersion')]", + "appSettings": [ + { + "name": "WEBSITE_NODE_DEFAULT_VERSION", + "value": "~20" + }, + { + "name": "MicrosoftAppType", + "value": "[parameters('appType')]" + }, + { + "name": "MicrosoftAppId", + "value": "[parameters('appId')]" + }, + { + "name": "MicrosoftAppPassword", + "value": "[parameters('appSecret')]" + } + ] + } + } + }, + { + "type": "Microsoft.Web/sites/config", + "apiVersion": "2016-08-01", + "name": "[concat(parameters('appServiceName'), '/web')]", + "location": "[variables('servicePlanLocation')]", + "dependsOn": [ + "[resourceId('Microsoft.Web/sites', parameters('appServiceName'))]" + ], + "properties": { + "numberOfWorkers": 1, + "defaultDocuments": [ + "Default.htm", + "Default.html", + "Default.asp", + "index.htm", + "index.html", + "iisstart.htm", + "default.aspx", + "index.php", + "hostingstart.html" + ], + "netFrameworkVersion": "v4.0", + "phpVersion": "", + "pythonVersion": "", + "nodeVersion": "", + "linuxFxVersion": "[parameters('linuxFxVersion')]", + "requestTracingEnabled": false, + "remoteDebuggingEnabled": false, + "httpLoggingEnabled": false, + "logsDirectorySizeLimit": 35, + "detailedErrorLoggingEnabled": false, + "publishingUsername": "[concat('$', parameters('appServiceName'))]", + "scmType": "LocalGit", + "use32BitWorkerProcess": true, + "webSocketsEnabled": false, + "alwaysOn": true, + "appCommandLine": "", + "managedPipelineMode": "Integrated", + "virtualApplications": [ + { + "virtualPath": "/", + "physicalPath": "site\\wwwroot", + "preloadEnabled": true, + "virtualDirectories": null + } + ], + "winAuthAdminState": 0, + "winAuthTenantState": 0, + "customAppPoolIdentityAdminState": false, + "customAppPoolIdentityTenantState": false, + "loadBalancing": "LeastRequests", + "routingRules": [], + "experiments": { + "rampUpRules": [] + }, + "autoHealEnabled": false, + "vnetName": "", + "minTlsVersion": "1.2", + "ftpsState": "Disabled", + "reservedInstanceCount": 0 + } + } + ] +} diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/parameters-for-template-AzureBot-new-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/parameters-for-template-AzureBot-new-rg.json new file mode 100644 index 0000000000..f180618138 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/parameters-for-template-AzureBot-new-rg.json @@ -0,0 +1,27 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "groupName": { + "value": "" + }, + "groupLocation": { + "value": "" + }, + "azureBotId": { + "value": "" + }, + "azureBotSku": { + "value": "S1" + }, + "azureBotRegion": { + "value": "global" + }, + "botEndpoint": { + "value": "" + }, + "appId": { + "value": "" + } + } +} \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/parameters-for-template-BotApp-new-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/parameters-for-template-BotApp-new-rg.json new file mode 100644 index 0000000000..a147121303 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/parameters-for-template-BotApp-new-rg.json @@ -0,0 +1,42 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "groupName": { + "value": "" + }, + "groupLocation": { + "value": "" + }, + "appServiceName": { + "value": "" + }, + "appServicePlanName": { + "value": "" + }, + "appServicePlanLocation": { + "value": "" + }, + "appServicePlanSku": { + "value": { + "name": "S1", + "tier": "Standard", + "size": "S1", + "family": "S", + "capacity": 1 + } + }, + "linuxFxVersion": { + "value": "" + }, + "appId": { + "value": "" + }, + "appSecret": { + "value": "" + }, + "appType": { + "value": "" + } + } +} \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/readme.md b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/readme.md new file mode 100644 index 0000000000..dbdfabf9a9 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/readme.md @@ -0,0 +1,27 @@ +# Usage +BotApp must be deployed prior to AzureBot. + +### Command line: +`az login`
+`az deployment sub create --template-file --location --parameters @` + +## Parameters for template-BotApp-new-rg.json: + +- **groupName**: (required) The name of the new Resource Group. +- **groupLocation**: (required) The location of the new Resource Group. +- **appServiceName**: (required) The location of the App Service Plan. +- **appServicePlanName**: (required) The name of the App Service Plan. +- **appServicePlanLocation**: The location of the App Service Plan. Defaults to use groupLocation. +- **appServicePlanSku**: The SKU of the App Service Plan. Defaults to Standard values. +- **appId**: (required) Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings. +- **appSecret**: (required for MultiTenant and SingleTenant) Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings. + +## Parameters for template-AzureBot-new-rg.json: + +- **groupName**: (required) The name of the new Resource Group. +- **groupLocation**: (required) The location of the new Resource Group. +- **azureBotId**: (required) The globally unique and immutable bot ID. Also used to configure the displayName of the bot, which is mutable. +- **azureBotSku**: The pricing tier of the Bot Service Registration. Allowed values are: F0, S1(default). +- **azureBotRegion**: Specifies the location of the new AzureBot. Allowed values are: global(default), westeurope. +- **botEndpoint**: Use to handle client messages, Such as `https://.azurewebsites.net/api/messages`. +- **appId**: (required) Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings. \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/template-AzureBot-new-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/template-AzureBot-new-rg.json new file mode 100644 index 0000000000..927307e0fc --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/template-AzureBot-new-rg.json @@ -0,0 +1,104 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "groupName": { + "type": "string", + "metadata": { + "description": "Specifies the name of the Resource Group." + } + }, + "groupLocation": { + "type": "string", + "metadata": { + "description": "Specifies the location of the Resource Group." + } + }, + "azureBotId": { + "type": "string", + "metadata": { + "description": "The globally unique and immutable bot ID." + } + }, + "azureBotSku": { + "type": "string", + "defaultValue": "S1", + "metadata": { + "description": "The pricing tier of the Bot Service Registration. Acceptable values are F0 and S1." + } + }, + "azureBotRegion": { + "type": "string", + "defaultValue": "global", + "metadata": { + "description": "" + } + }, + "botEndpoint": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "Use to handle client messages, Such as https://.azurewebsites.net/api/messages." + } + }, + "appId": { + "type": "string", + "metadata": { + "description": "Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings." + } + } + }, + "variables": { + "botEndpoint": "[if(empty(parameters('botEndpoint')), concat('https://', parameters('azureBotId'), '.azurewebsites.net/api/messages'), parameters('botEndpoint'))]" + }, + "resources": [ + { + "name": "[parameters('groupName')]", + "type": "Microsoft.Resources/resourceGroups", + "apiVersion": "2018-05-01", + "location": "[parameters('groupLocation')]", + "properties": {} + }, + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2018-05-01", + "name": "storageDeployment", + "resourceGroup": "[parameters('groupName')]", + "dependsOn": [ + "[resourceId('Microsoft.Resources/resourceGroups/', parameters('groupName'))]" + ], + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": {}, + "variables": {}, + "resources": [ + { + "apiVersion": "2021-03-01", + "type": "Microsoft.BotService/botServices", + "name": "[parameters('azureBotId')]", + "location": "[parameters('azureBotRegion')]", + "kind": "azurebot", + "sku": { + "name": "[parameters('azureBotSku')]" + }, + "properties": { + "name": "[parameters('azureBotId')]", + "displayName": "[parameters('azureBotId')]", + "iconUrl": "https://docs.botframework.com/static/devportal/client/images/bot-framework-default.png", + "endpoint": "[variables('botEndpoint')]", + "msaAppId": "[parameters('appId')]", + "luisAppIds": [], + "schemaTransformationVersion": "1.3", + "isCmekEnabled": false, + "isIsolated": false + } + } + ] + } + } + } + ] +} \ No newline at end of file diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/template-BotApp-new-rg.json b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/template-BotApp-new-rg.json new file mode 100644 index 0000000000..ff144bfd5f --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/deploymentTemplates/linux/deployWithNewResourceGroup/template-BotApp-new-rg.json @@ -0,0 +1,244 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "groupName": { + "type": "string", + "metadata": { + "description": "Specifies the name of the Resource Group." + } + }, + "groupLocation": { + "type": "string", + "metadata": { + "description": "Specifies the location of the Resource Group." + } + }, + "appServiceName": { + "type": "string", + "metadata": { + "description": "The globally unique name of the Web App." + } + }, + "appServicePlanName": { + "type": "string", + "metadata": { + "description": "The name of the App Service Plan." + } + }, + "appServicePlanLocation": { + "type": "string", + "defaultValue": "", + "metadata": { + "description": "The location of the App Service Plan." + } + }, + "appServicePlanSku": { + "type": "object", + "defaultValue": { + "name": "S1", + "tier": "Standard", + "size": "S1", + "family": "S", + "capacity": 1 + }, + "metadata": { + "description": "The SKU of the App Service Plan. Defaults to Standard values." + } + }, + "linuxFxVersion": { + "type": "string", + "defaultValue": "NODE|20-LTS" + }, + "appId": { + "type": "string", + "metadata": { + "description": "Active Directory App ID or User-Assigned Managed Identity Client ID, set as MicrosoftAppId in the Web App's Application Settings." + } + }, + "appSecret": { + "type": "string", + "metadata": { + "description": "Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings. Required for MultiTenant and SingleTenant app types." + } + }, + "appType": { + "defaultValue": "MultiTenant", + "type": "string", + "allowedValues": [ + "MultiTenant", + "SingleTenant", + "UserAssignedMSI" + ] + } + }, + "variables": { + "appServicePlanName": "[parameters('appServicePlanName')]", + "resourcesLocation": "[if(empty(parameters('appServicePlanLocation')), parameters('groupLocation'), parameters('appServicePlanLocation'))]", + "appServiceName": "[parameters('appServiceName')]", + "resourceGroupId": "[concat(subscription().id, '/resourceGroups/', parameters('groupName'))]" + }, + "resources": [ + { + "name": "[parameters('groupName')]", + "type": "Microsoft.Resources/resourceGroups", + "apiVersion": "2018-05-01", + "location": "[parameters('groupLocation')]", + "properties": {} + }, + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2018-05-01", + "name": "storageDeployment", + "resourceGroup": "[parameters('groupName')]", + "dependsOn": [ + "[resourceId('Microsoft.Resources/resourceGroups/', parameters('groupName'))]" + ], + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": {}, + "variables": {}, + "resources": [ + { + "comments": "Create a new App Service Plan", + "type": "Microsoft.Web/serverfarms", + "name": "[variables('appServicePlanName')]", + "apiVersion": "2018-02-01", + "location": "[variables('resourcesLocation')]", + "sku": "[parameters('appServicePlanSku')]", + "kind": "linux", + "properties": { + "name": "[variables('appServicePlanName')]", + "perSiteScaling": false, + "reserved": true, + "targetWorkerCount": 0, + "targetWorkerSizeId": 0 + } + }, + { + "comments": "Create a Web App using the new App Service Plan", + "type": "Microsoft.Web/sites", + "apiVersion": "2015-08-01", + "name": "[parameters('appServiceName')]", + "location": "[variables('resourcesLocation')]", + "kind": "app,linux", + "dependsOn": [ + "[concat(variables('resourceGroupId'), '/providers/Microsoft.Web/serverfarms/', variables('appServicePlanName'))]" + ], + "properties": { + "enabled": true, + "hostNameSslStates": [ + { + "name": "[concat(parameters('appServiceName'), '.azurewebsites.net')]", + "sslState": "Disabled", + "hostType": "Standard" + }, + { + "name": "[concat(parameters('appServiceName'), '.scm.azurewebsites.net')]", + "sslState": "Disabled", + "hostType": "Repository" + } + ], + "serverFarmId": "[variables('appServicePlanName')]", + "reserved": true, + "scmSiteAlsoStopped": false, + "clientAffinityEnabled": false, + "clientCertEnabled": false, + "hostNamesDisabled": false, + "containerSize": 0, + "dailyMemoryTimeQuota": 0, + "httpsOnly": false, + "siteConfig": { + "linuxFxVersion": "[parameters('linuxFxVersion')]", + "appSettings": [ + { + "name": "WEBSITE_NODE_DEFAULT_VERSION", + "value": "~20" + }, + { + "name": "MicrosoftAppType", + "value": "[parameters('appType')]" + }, + { + "name": "MicrosoftAppId", + "value": "[parameters('appId')]" + }, + { + "name": "MicrosoftAppPassword", + "value": "[parameters('appSecret')]" + } + ] + } + } + }, + { + "type": "Microsoft.Web/sites/config", + "apiVersion": "2016-08-01", + "name": "[concat(parameters('appServiceName'), '/web')]", + "location": "[variables('resourcesLocation')]", + "dependsOn": [ + "[concat(variables('resourceGroupId'), '/providers/Microsoft.Web/sites/', parameters('appServiceName'))]" + ], + "properties": { + "numberOfWorkers": 1, + "defaultDocuments": [ + "Default.htm", + "Default.html", + "Default.asp", + "index.htm", + "index.html", + "iisstart.htm", + "default.aspx", + "index.php", + "hostingstart.html" + ], + "netFrameworkVersion": "v4.0", + "phpVersion": "", + "pythonVersion": "", + "nodeVersion": "", + "linuxFxVersion": "[parameters('linuxFxVersion')]", + "requestTracingEnabled": false, + "remoteDebuggingEnabled": false, + "httpLoggingEnabled": true, + "logsDirectorySizeLimit": 35, + "detailedErrorLoggingEnabled": false, + "publishingUsername": "[concat('$', parameters('appServiceName'))]", + "scmType": "LocalGit", + "use32BitWorkerProcess": true, + "webSocketsEnabled": false, + "alwaysOn": true, + "appCommandLine": "", + "managedPipelineMode": "Integrated", + "virtualApplications": [ + { + "virtualPath": "/", + "physicalPath": "site\\wwwroot", + "preloadEnabled": true, + "virtualDirectories": null + } + ], + "winAuthAdminState": 0, + "winAuthTenantState": 0, + "customAppPoolIdentityAdminState": false, + "customAppPoolIdentityTenantState": false, + "loadBalancing": "LeastRequests", + "routingRules": [], + "experiments": { + "rampUpRules": [] + }, + "autoHealEnabled": false, + "vnetName": "", + "minTlsVersion": "1.2", + "ftpsState": "Disabled", + "reservedInstanceCount": 0 + } + } + ] + } + } + } + ] +} diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/index.js b/samples/javascript_nodejs/86.bot-authentication-fic/index.js new file mode 100644 index 0000000000..4461fd31da --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/index.js @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +const path = require('path'); +const dotenv = require('dotenv'); +const restify = require('restify'); +const { FederatedServiceClientCredentialsFactory } = require('botframework-connector'); + +// Import required bot configuration. +const ENV_FILE = path.join(__dirname, '.env'); +dotenv.config({ path: ENV_FILE }); + +// Import required bot services. +// See https://aka.ms/bot-services to learn more about the different parts of a bot. +const { + CloudAdapter, + ConfigurationBotFrameworkAuthentication +} = require('botbuilder'); + +// This bot's main dialog. +const { EchoBot } = require('./bot'); + +(async () => { + try { + // Create HTTP server. + const server = restify.createServer(); + server.use(restify.plugins.bodyParser()); + + server.listen(process.env.port || process.env.PORT || 3978, () => { + console.log(`\n${ server.name } listening to ${ server.url }`); + console.log('\nGet Bot Framework Emulator: https://aka.ms/botframework-emulator'); + console.log('\nTo talk to your bot, open the emulator select "Open Bot"'); + }); + + // Create the Federated Service Client Credentials to be used as the ServiceClientCredentials for the Bot Framework SDK. + const serviceClientCredentialsFactory = new FederatedServiceClientCredentialsFactory( + process.env.MicrosoftAppId, + process.env.MicrosoftAppClientId, + process.env.MicrosoftAppTenantId + ); + + const botFrameworkAuthentication = new ConfigurationBotFrameworkAuthentication(process.env, serviceClientCredentialsFactory); + + // Create adapter. + // See https://aka.ms/about-bot-adapter to learn more about how bots work. + const adapter = new CloudAdapter(botFrameworkAuthentication); + // Catch-all for errors. + const onTurnErrorHandler = async (context, error) => { + // This check writes out errors to console log .vs. app insights. + // NOTE: In production environment, you should consider logging this to Azure + // application insights. See https://aka.ms/bottelemetry for telemetry + // configuration instructions. + console.error(`\n [onTurnError] unhandled error: ${ error }`); + + // Send a trace activity, which will be displayed in Bot Framework Emulator + await context.sendTraceActivity( + 'OnTurnError Trace', + `${ error }`, + 'https://www.botframework.com/schemas/error', + 'TurnError' + ); + + // Send a message to the user + await context.sendActivity('The bot encountered an error or bug.'); + await context.sendActivity('To continue to run this bot, please fix the bot source code.'); + }; + + // Set the onTurnError for the singleton CloudAdapter. + adapter.onTurnError = onTurnErrorHandler; + + // Create the main dialog. + const myBot = new EchoBot(); + + // Listen for incoming requests. + server.post('/api/messages', async (req, res) => { + // Route received a request to adapter for processing + await adapter.process(req, res, (context) => myBot.run(context)); + }); + + // Listen for Upgrade requests for Streaming. + server.on('upgrade', async (req, socket, head) => { + // Create an adapter scoped to this WebSocket connection to allow storing session data. + const streamingAdapter = new CloudAdapter(botFrameworkAuthentication); + // Set onTurnError for the CloudAdapter created for each connection. + streamingAdapter.onTurnError = onTurnErrorHandler; + + await streamingAdapter.process(req, socket, head, (context) => myBot.run(context)); + }); + } catch (error) { + console.log(error); + } +})(); diff --git a/samples/javascript_nodejs/86.bot-authentication-fic/package.json b/samples/javascript_nodejs/86.bot-authentication-fic/package.json new file mode 100644 index 0000000000..591eaaad32 --- /dev/null +++ b/samples/javascript_nodejs/86.bot-authentication-fic/package.json @@ -0,0 +1,32 @@ +{ + "name": "bot-authentication-fic", + "version": "1.0.0", + "description": "Bot Builder v4 bot authentication with Federation Identity Certificate (FIC) sample", + "author": "Microsoft", + "license": "MIT", + "main": "index.js", + "scripts": { + "start": "node ./index.js", + "watch": "nodemon ./index.js", + "lint": "eslint .", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://github.com" + }, + "dependencies": { + "botbuilder": "^4.23.0", + "dotenv": "^8.2.0", + "restify": "~10.0.0" + }, + "devDependencies": { + "eslint": "^7.0.0", + "eslint-config-standard": "^14.1.1", + "eslint-plugin-import": "^2.20.2", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-standard": "^4.0.1", + "nodemon": "~2.0.4" + } +}