Managing App Services
This document provides a comprehensive guide to managing your App Services, covering essential operations from creation and configuration to scaling and deletion.
Creating an App Service
You can create a new App Service through the Azure portal, Azure CLI, or programmatically using SDKs.
Using the Azure Portal
- Navigate to the Azure portal.
- Click on "Create a resource".
- Search for "Web App" or "App Service" and select it.
- Fill in the required details: Subscription, Resource Group, Name, Runtime Stack, Region, and App Service Plan.
- Click "Review + create" and then "Create".
Using Azure CLI
Use the following command to create a new App Service:
az webapp create --resource-group <resource-group-name> --name <app-name> --plan <app-service-plan-name> --runtime "dotnetcore|6.0"
Configuring Your App Service
App Services offer extensive configuration options to tailor your application's environment.
General Settings
- Runtime Stack: Select the language and version for your application (e.g., .NET, Node.js, Python, Java).
- Platform: Choose between 32-bit or 64-bit.
- Always On: Keep your application loaded and ready to respond to requests, even during periods of inactivity.
- Web Sockets: Enable or disable WebSocket support.
Deployment Slots
Deployment slots allow you to manage multiple versions of your application in production without downtime. You can deploy to a staging slot, test it, and then swap it into production.
App Service Plan
The App Service plan defines the location, size, features, cost, and computing resources of your app. You can scale your plan up or out.
- Scale Up: Increase the instance size or performance tier of your App Service Plan.
- Scale Out: Increase the number of instances running your application.
Scaling Your App Service
App Services can be scaled manually or automatically based on performance metrics.
Manual Scaling
In the Azure portal, navigate to your App Service and under "Scale out (App Service plan)", you can manually adjust the number of instances.
Autoscaling
Autoscaling allows your application to scale up or down automatically based on predefined rules. You can configure rules based on CPU percentage, memory usage, HTTP queue length, and more.
# Example autoscaling rule for Azure CLI
az monitor autoscale create \
--resource-group <resource-group-name> \
--resource <app-service-plan-name> \
--min-workers 1 \
--max-workers 5 \
--default-workers 2
Try Autoscaling (Simulated)
Click the button below to simulate an increase in load and observe how the number of instances would theoretically scale.
Current Instances: 1
Monitoring and Diagnostics
It's essential to monitor your App Service's performance and health. App Services integrate with Azure Monitor for comprehensive diagnostics.
- Application Insights: Provides deep insights into your application's performance, dependencies, and usage.
- Diagnostic Logs: Collect logs for web server, application, and deployment activities.
Stopping and Deleting an App Service
You can stop an App Service to reduce costs when it's not in use. Deleting an App Service is a permanent action.
Stopping
In the Azure portal, under "Overview", you will find a "Stop" button.
Deleting
Navigate to your App Service in the Azure portal, click "Delete" at the top, and confirm your action. Remember to delete the associated App Service Plan if it's no longer needed.
For more advanced management tasks, refer to the API Reference.