Host your Node Teams app in Azure
You will need:
- A Microsoft Azure account. For testing you can use a free trial account and migrate to a production ready account when the app is ready for public use. If you have never used Azure before, you can get started by creating a new free account. If you already have an Azure account you can use your existing account to host this app for free.
- Visual Studio Code. This free code editor can be downloaded at: Visual Studio Code. Once VS Code is installed, add support for Azure deployment by clicking this link to install the App service extension.
- A downloaded sample app to deploy. See Getting Started with Node.JS to download and test the sample app. Return to this topic when it is time to host the app.
Open the app in VS.Code
Open your preferred shell, and navigate to the root of the sample app msteams-samples-hello-world-nodejs, then enter:
VS Code will start, pointing to the root directory for the sample.
Configure your Azure account
In VS Code, click on the Azure icon in the left hand tool bar.
This will display the Azure sign in and management pane.
Click on Sign in to Azure.... A dialog will open in the lower right corner of VS Code. Read the instructions and Click Copy & Open. A web page will be displayed where you can enter a confirmation code.
Right click where it says Code, and select paste from the right click menu. This will enter a code provided by the previous dialog.
You can now return to VS Code, where the Azure pane will now look something like this:
What you actually see will depend on the type of account you have with Azure.
Deploy the app to Azure
Look for the up-arrow button at the top of the Azure pane in VS Code. This is the Deploy to Web App... button. click on it to start.
You will first be asked if you want to create a new web app. Choose this option.
You will then be asked to enter a globally unique name for the new Web App. Do so and press enter.
You will then be asked to select a Node.js runtime for your app. Choose the version marked LTS - Recommended for new apps.
You will see several status messages as your app is deployed.
You may be asked if you would like to update your workspace configuration to run
npm install on the target server. Choose yes.
You may then be asked if you want to always deploy the workspace. You can answer yes to this also.
Finally you will see this message, assuming everything went well.
Configure environment variables
Environment variables are used in Azure to securely hold sensitive information like app ids and passwords. You will need to manually add the following Application Settings (environment variables) in VS Code by right-clicking Application Settings.
MICROSOFT_APP_ID=<YOUR BOT'S APP ID> MICROSOFT_APP_PASSWORD=<YOUR BOT'S PASSWORD> WEBSITE_NODE_DEFAULT_VERSION=8.9.4
The values for these settings were generated by App Studio in Teams when you were setting up your app. If you have not run App Studio yet, you can update your app and redeploy after you have done so.
Testing your app on Azure
Navigate to the following URLs and confirm that the correct pages appear. Replace "YourAzureSite" with the correct URL for your specific site.