Skip to content

02. First Deploy

Deploy the Spring Boot reference app to Azure App Service in about five minutes with az webapp up.

Keep this tutorial simple

This page covers the fastest path to a working deployment. For VNet integration, private endpoints, and managed identity, use Recipe: Private Network Deploy.

flowchart TD
    DEV[Local Java app] -->|Build JAR| ARTIFACT[Spring Boot artifact]
    ARTIFACT -->|az webapp up| APP[Azure App Service\nLinux Java 17\nB1]
    USER[Browser or curl] -->|HTTPS| APP
    APP --> LOGS[App Service logs]

    style APP fill:#0078d4,color:#fff
    style ARTIFACT fill:#E3F2FD
    style LOGS fill:#E8F5E9

Prerequisites

  • Completed 01. Local Run
  • Azure CLI authenticated with az login
  • Maven or Gradle installed

Main Content

flowchart TD
    A[Set RG APP_NAME LOCATION] --> B[Build the app]
    B --> C[Run az webapp up]
    C --> D[Verify site and health endpoint]
    D --> E[View logs]
    E --> F[Clean up]

Step 1: Set deployment variables

RG="rg-java-guide"
APP_NAME="app-java-guide-abc123"
LOCATION="koreacentral"
Command/Parameter Purpose
RG="rg-java-guide" Defines the resource group that az webapp up creates or reuses.
APP_NAME="app-java-guide-abc123" Sets the globally unique App Service app name.
LOCATION="koreacentral" Selects the Azure region for the new App Service resources.
Expected output
Variables prepared for resource group rg-java-guide and app app-java-guide-abc123.

Step 2: Build the app

Choose the command that matches your project.

mvn package
Command/Parameter Purpose
mvn package Builds the Spring Boot application and creates the deployable artifact in target/.
mvn Runs the Maven build tool for the current project.
package Runs the Maven package lifecycle phase that produces the JAR file used for deployment.
gradle build
Command/Parameter Purpose
gradle build Builds the application and runs the standard Gradle build pipeline.
gradle Runs the Gradle build tool for the current project.
build Produces the deployable artifact in build/libs/ for App Service deployment.
Expected output
BUILD SUCCESS

Step 3: Deploy with az webapp up

az webapp up --name $APP_NAME --resource-group $RG --location $LOCATION --runtime "JAVA:17-java17" --sku B1
Command/Parameter Purpose
az webapp up --name $APP_NAME --resource-group $RG --location $LOCATION --runtime "JAVA:17-java17" --sku B1 Creates the resource group, App Service plan, and web app if needed, then deploys the current app to App Service.
--name $APP_NAME Uses the chosen globally unique web app name.
--resource-group $RG Places all created resources in the target resource group.
--location $LOCATION Creates the App Service resources in the selected Azure region.
--runtime "JAVA:17-java17" Selects the Linux Java 17 runtime stack.
--sku B1 Uses the Basic B1 pricing tier for a low-cost first deployment.
Expected output
Webapp URL: http://app-java-guide-abc123.azurewebsites.net
Creating AppServicePlan 'appsvc_rg_java_guide'
Creating webapp 'app-java-guide-abc123'
Configuring default logging for the app
Deployment successful

Step 4: Verify deployment

WEB_APP_URL="https://$(az webapp show --resource-group $RG --name $APP_NAME --query defaultHostName --output tsv)"
curl $WEB_APP_URL/health
az webapp show --resource-group $RG --name $APP_NAME --query "{name:name,state:state,defaultHostName:defaultHostName}" --output json
Command/Parameter Purpose
WEB_APP_URL="https://$(az webapp show --resource-group $RG --name $APP_NAME --query defaultHostName --output tsv)" Builds the site URL from the deployed web app hostname.
az webapp show --resource-group $RG --name $APP_NAME --query defaultHostName --output tsv Returns only the default hostname so the shell can build the site URL.
--resource-group $RG Queries the web app inside the tutorial resource group.
--name $APP_NAME Selects the deployed web app to inspect.
--query defaultHostName Extracts only the default hostname value from the response.
--output tsv Formats the hostname as plain text for shell substitution.
curl $WEB_APP_URL/health Confirms the Spring Boot health endpoint responds after deployment.
az webapp show --resource-group $RG --name $APP_NAME --query "{name:name,state:state,defaultHostName:defaultHostName}" --output json Verifies the app is running and returns the default hostname.
--query "{name:name,state:state,defaultHostName:defaultHostName}" Limits the response to the app name, state, and default hostname fields.
--output json Formats the verification result as JSON.
Expected output
{
  "status": "healthy",
  "timestamp": "2026-04-10T09:30:00Z"
}

Step 5: View logs

az webapp log tail --resource-group $RG --name $APP_NAME
Command/Parameter Purpose
az webapp log tail --resource-group $RG --name $APP_NAME Streams live application logs from the deployed web app.
--resource-group $RG Targets the resource group that contains the app.
--name $APP_NAME Selects the specific App Service instance for log streaming.
Expected output
2026-04-10T09:32:14.221Z INFO 1 --- [main] c.example.guide.Application : Started Application in 8.421 seconds
2026-04-10T09:32:20.014Z INFO 1 --- [nio-8080-exec-1] c.e.g.controller.HealthController : Health endpoint invoked

Step 6: Clean up

az group delete --name $RG --yes --no-wait
Command/Parameter Purpose
az group delete --name $RG --yes --no-wait Deletes the resource group and all App Service resources created by this tutorial.
--name $RG Targets the tutorial resource group for removal.
--yes Confirms the delete operation without prompting.
--no-wait Starts the deletion and returns immediately.

Troubleshooting

az webapp up fails because the app name is already taken

Choose a more unique APP_NAME value and run the deploy command again.

The app URL loads but /health fails

Use log streaming to check startup output:

az webapp log tail --resource-group $RG --name $APP_NAME
Command/Parameter Purpose
az webapp log tail --resource-group $RG --name $APP_NAME Shows live startup and request logs so you can diagnose why the app is not healthy yet.
--resource-group $RG Reads logs from the resource group that contains the app.
--name $APP_NAME Streams logs for the specific Java web app.

Run It in the Portal

Portal view: Web App Overview blade - first-deploy verification surface

Azure portal Overview blade for app-test-20251107 (Web App) with a command bar (Browse, Stop, Swap, Restart, Delete, Refresh, Download publish profile, Reset publish profile, Share to mobile, Send us your feedback) and an Essentials panel showing Resource group rg-test-20251107, Status Running, Location Korea Central, Subscription Visual Studio Enterprise Subscription, Subscription ID 00000000-0000-0000-0000-000000000000, Default domain app-test-20251107.azurewebsites.net, App Service Plan asp-test-20251107 (P0v3: 1), Operating System Linux, and Health Check Not Configured. The Properties tab is selected (next to Monitoring, Logs, Capabilities, Notifications (1), Recommendations) and surfaces Web app (Publishing model: Code, Runtime Stack: Python - 3.11, Runtime status: Healthy), Domains (2 Domains View all), Hosting (Plan Type: App Service plan, Instance Count: 1, SKU and size: Premium0V3 (P0v3) with Scale up link), Deployment Center (Last deployment: Successful on Thursday, November 6, 10:58:01 PM, Deployment provider: None), Application Insights (Name: ai-test-20251107, Region: Korea Central), and Networking (Inbound IP addresses: 20.200.197.3, 2603:1040:f05:3::208, Private endpoint connections: 0 private endpoints, Virtual network integration: Not configured). Left nav under the search box lists Overview (selected), Activity log, Access control (IAM), Tags, Diagnose and solve problems, Microsoft Defender for Cloud, Events (preview), Log stream, AI (preview), Resource visualizer, with collapsed groups Deployment, Settings, Performance, App Service plan, Development Tools, API, Monitoring, Automation, and Support + troubleshooting.

After running the az webapp deploy commands in this tutorial, the Overview blade is the first Portal verification surface. The Essentials panel confirms the app the CLI created or reused: Status: Running, Operating System: Linux, Default domain, and the attached App Service Plan are all visible on this blade. The screenshot shows Runtime Stack: Python - 3.11 because the underlying capture was taken from a Python app; for the Java SE app this tutorial deploys, the equivalent value is Java - 17 and Runtime status: Healthy then confirms the Spring Boot jar started cleanly. Use the Default domain value to open the deployed app in a browser, which is the Portal-side check that corresponds to the tutorial's /health verification step.

See Also

Sources