Deploying Applications

This guide covers the essential steps and considerations for deploying your applications to MSDN App Services. We'll walk you through various deployment methods, configuration options, and best practices to ensure a smooth and efficient deployment process.

Deployment Methods

MSDN App Services supports multiple deployment methods to suit your workflow and application type:

1. Git Deployment

This is a common and flexible method. You can connect your local Git repository or a remote repository (like GitHub, GitLab, or Azure DevOps) directly to your App Service. New commits to your main branch will automatically trigger a deployment.

Tip: For continuous integration and continuous delivery (CI/CD), integrate with a CI/CD pipeline tool.

To set up Git deployment:

  1. Navigate to your App Service in the MSDN portal.
  2. Under "Deployment," select "Deployment Center."
  3. Choose "Local Git" or "GitHub" (or your preferred provider) and follow the on-screen instructions.

2. FTP/FTPS Deployment

For simpler deployments or when Git is not an option, you can use FTP or FTPS to upload your application files directly to the App Service's file system.

You'll need to retrieve the FTP credentials from the "Deployment Center" or the "Overview" page of your App Service.

3. ZIP Deploy

This method allows you to deploy a ZIP archive of your application files. It's useful for quick deployments or when dealing with complex directory structures.

You can use the Kudu API or the Azure CLI to perform ZIP deployments.

# Example using Azure CLI for ZIP deploy
az webapp deploy --resource-group MyResourceGroup --name MyUniqueAppName --src-path /path/to/your/app.zip --type zip

4. Docker Container Deployment

If your application is containerized, MSDN App Services can host your Docker containers. You can deploy from a public or private container registry.

Requirements:

In the MSDN portal, under "Deployment," select "Container settings" to configure your container image and registry.

Deployment Slots

Deployment slots are a powerful feature that allows you to manage different versions of your application. You can deploy to a staging slot, test it, and then "swap" it into production with zero downtime.

Benefits of Deployment Slots:

You can create and manage deployment slots from the "Deployment slots" section of your App Service in the MSDN portal.

Configuration Management

Proper configuration management is crucial for successful deployments. MSDN App Services provides several ways to manage application settings:

Application Settings

Store your application's configuration values (like database connection strings, API keys, etc.) as key-value pairs. These are injected as environment variables into your application.

Access this under "Configuration" -> "Application settings" in the portal.

Connection Strings

Similar to application settings, but specifically for connection strings to databases and other services. These are also injected as environment variables.

Access this under "Configuration" -> "Connection strings" in the portal.

Environment Variables

Understand how your application reads environment variables, as App Service settings and connection strings are exposed this way.

Example: Reading Environment Variables in Node.js

// Get connection string
const connectionString = process.env.DATABASE_URL;
// Get API key
const apiKey = process.env.API_KEY;

if (!connectionString || !apiKey) {
    console.error("Missing environment variables!");
    process.exit(1);
}

// Use connectionString and apiKey in your application logic...

Troubleshooting Deployments

If your deployment fails or your application doesn't behave as expected after deployment, here are some common troubleshooting steps:

For more in-depth troubleshooting, refer to the MSDN Diagnostics and Troubleshooting tools available for App Services.