Scenario: How to scale out web app base on custom metrics. For example: request, response time and etc.
Currently, Web App Linux only CPU and memory are available.
Here is the end to end steps/screenshots:
**Step 1. Use the portal to create an Azure AD application and service principal that can access resources
- Click “App registration”  
- “New registration”  
- Enter a Name and click Register  
- In Overview page, you can find the Application Id and Tenant Id.  
- Create a client secret.  

- Copy the client secret in Azure Portal 
For more information: https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal
**Step 2. Add app roles in your application and receive them in the token
- Go to your resource group and “Access Control” and “Add a role assignment”  
- Select “Contributor” and select your app (Registered in Step1)  
- Go to your App Service Plan  
- Select “Reader” Role  
- Publish your function app.  
- Test Your Function App in Azure Portal  
- Verify the Instance Count in Azure Portal  
- Get the Function URI:  

- Test it in browser.  
- Verify it in Azure Portal  
For more information: https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-add-app-roles-in-azure-ad-apps
**Step 3. Setup an alert to change capacity
- Create an alert and choose a custom metric  
- Create a action group and action type “Webhook”, the function URI is from step2.8  
- Save alert  
- Simulate a User Load and verify the Instance Count:  



- Instance Count changed to 5 
| 1 | using System; | 
HTH. 2019-11-18 By Jacky
