Azure Spring Apps is the new name for the Azure Spring Cloud service. Although the service has a new name, you'll see the old name in some places for a while as we work to update assets such as screenshots, videos, and diagrams.
This quickstart shows how to deploy a Spring Boot web application to Azure Spring Apps. The sample project is a simple ToDo application to add tasks, mark when they're complete, and then delete them. The following screenshot shows the application:
This application is a typical three-layers web application with the following layers:
A backend Spring web application that uses Spring Data JPA to access a relational database.
A relational database. For localhost, the application uses H2 Database Engine. For Azure Spring Apps, the application uses Azure Database for PostgreSQL. For more information about Azure Database for PostgreSQL, see Flexible Server documentation.
The following diagram shows the architecture of the system:
This article provides the following options for deploying to Azure Spring Apps:
The Azure portal option is the easiest and the fastest way to create resources and deploy applications with a single click. This option is suitable for Spring developers who want to quickly deploy applications to Azure cloud services.
The Azure portal + Maven plugin option provides a more conventional way to create resources and deploy applications step by step. This option is suitable for Spring developers using Azure cloud services for the first time.
The Azure Developer CLI option is a more efficient way to automatically create resources and deploy applications through simple commands. The Azure Developer CLI uses a template to provision the Azure resources needed and to deploy the application code. This option is suitable for Spring developers who are familiar with Azure cloud services.
This article provides the following options for deploying to Azure Spring Apps:
The Azure portal option is the easiest and the fastest way to create resources and deploy applications with a single click. This option is suitable for Spring developers who want to quickly deploy applications to Azure cloud services.
The Azure portal + Maven plugin option provides a more conventional way to create resources and deploy applications step by step. This option is suitable for Spring developers using Azure cloud services for the first time.
The Azure CLI option uses a powerful command line tool to manage Azure resources. This option is suitable for Spring developers who are familiar with Azure cloud services.
The Deploy to Azure button in the next section launches an Azure portal experience that downloads a JAR package from the ASA-Samples-Web-Application releases page on GitHub. No local preparation steps are needed.
Although you use the Azure portal in later steps, you must use the Bash command line to prepare the project locally. Use the following steps to clone and run the app locally:
Use the following command to clone the sample project from GitHub:
Use the following command to build the sample project with Maven:
cd ASA-Samples-Web-Application
./mvnw clean package
Use the following command to run the sample application:
java -jar web/target/simple-todo-web.jar
Go to http://localhost:8080 in your browser to access the application.
3. Prepare the cloud environment
The main resources required to run this sample are an Azure Spring Apps instance and an Azure Database for PostgreSQL instance. This section provides the steps to create these resources.
This section uses a Deploy to Azure button to launch a deployment experience in the Azure portal. This experience uses an ARM template to create Azure resources.
3.1. Sign in to the Azure portal
Go to the Azure portal and enter your credentials to sign in to the portal. The default view is your service dashboard.
3.2. Create Azure resources
Use the following steps to create all the Azure resources that the app depends on:
Select the following Deploy to Azure button to launch the deployment experience in the Azure portal:
Fill out the form on the Basics tab. Use the following table as a guide for completing the form:
Setting
Suggested value
Description
Subscription
Your subscription name.
The Azure subscription that you want to use for your server. If you have multiple subscriptions, choose the subscription in which you'd like to be billed for the resource.
Resource group
myresourcegroup
A new resource group name or an existing one from your subscription.
Region
The region closest to your users.
The region is used to create the resource group.
Postgre SQL Admin Password
N/A
The password for the PostgreSQL Server administrator.
Postgre SQL User Password
N/A
The password for the PostgreSQL application user, which is used in the application.
Select Review and Create to review your selections. Then, select Create to deploy the app to Azure Spring Apps.
On the toolbar, select the Notifications icon (a bell) to monitor the deployment process. After the deployment finishes, you can select Pin to dashboard, which creates a tile for this service on your Azure portal dashboard as a shortcut to the service's Overview page. Select Go to resource to open the service's Overview page.
3.1. Sign in to the Azure portal
Go to the Azure portal, enter your credentials, and sign in to the portal. The default view is your service dashboard.
3.2. Create an Azure Spring Apps instance
Use the following steps to create the service instance:
Select Create a resource in the corner of the Azure portal.
Select Compute > Azure Spring Apps.
Fill out the Basics form with the following information:
Setting
Suggested value
Description
Subscription
Your subscription name.
The Azure subscription that you want to use for your server. If you have multiple subscriptions, choose the subscription in which you'd like to be billed for the resource.
Resource group
myresourcegroup
A new resource group name or an existing one from your subscription.
Name
myasa
A unique name that identifies your Azure Spring Apps service. The name must be between 4 and 32 characters long and can contain only lowercase letters, numbers, and hyphens. The first character of the service name must be a letter and the last character must be either a letter or a number.
Plan
Enterprise
The pricing plan that determines the resource and cost associated with your instance.
Region
The region closest to your users.
The location that is closest to your users.
Zone Redundant
Unselected
The option to create your Azure Spring Apps service in an Azure availability zone. This feature isn't currently supported in all regions.
Software IP plan
Pay-as-You-Go
Pay as you go with Azure Spring Apps.
Terms
Selected
The agreement checkbox associated with Marketplace offering. You're required to select this checkbox.
Deploy sample project
Unselected
The option to use the built-in sample application.
Select Review and Create to review your selections. Then, select Create to provision the Azure Spring Apps instance.
On the toolbar, select the Notifications icon (a bell) to monitor the deployment process. After the deployment finishes, you can select Pin to dashboard, which creates a tile for this service on your Azure portal dashboard as a shortcut to the service's Overview page.
Select Go to resource to go to the Azure Spring Apps Overview page.
3.3. Prepare the PostgreSQL instance
Use the following steps to create an Azure Database for PostgreSQL server:
In the Azure portal, select Create a resource.
Select Databases > Azure Database for PostgreSQL Flexible Server.
Fill out the Basics tab with the following information:
Server name: my-demo-pgsql
Region: East US
PostgreSQL version: 14
Workload type: Development
Enable high availability: unselected
Authentication method: PostgreSQL authentication only
Admin username: myadmin
Password and Confirm password: Enter a password.
Configure the Networking tab using the following information:
Connectivity method: Public access (allowed IP addresses)
Allow public access from any Azure service within Azure to this server: selected
Select Review + create to review your selections, then select Create to provision the server. This operation might take a few minutes.
Go to your PostgreSQL server in the Azure portal.
Select Databases from the navigation menu to create a database - for example, Todo.
3.4. Connect app instance to PostgreSQL instance
Use the following steps to connect your service instances:
Go to your Azure Spring Apps instance in the Azure portal.
From the navigation pane, open Apps and then select Create App.
On the Create App page, for the app name, use simple-todo-web and leave all the other fields with their default values.
Select Create to finish creating the app and then select the app to view the details.
Select Service Connector from the navigation pane and then select Create to create a new service connection.
Fill out the Basics tab with the following information:
Service type: DB for PostgreSQL flexible server
Connection name: Populated with an automatically generated name that you can modify.
Subscription: Select your subscription.
PostgreSQL flexible server: my-demo-pgsql
PostgreSQL database: Select the database you created.
Client type: SpringBoot
Configure the Next: Authentication tab with the following information:
Select the authentication type you'd like to use between your compute service and target service.: Select Connection string.
Continue with...: Select Database credentials
Username: myadmin
Password: Enter your password.
Select Next: Networking. Use the default option Configure firewall rules to enable access to target service..
Select Next: Review and Create to review your selections and then select Create to create the connection.
3.1. Provide names for each resource
Create variables to hold the resource names by using the following commands. Be sure to replace the placeholders with your own values.
Specifying 0.0.0.0 enables public access from any resources deployed within Azure to access your server.
3.5. Connect app instance to PostgreSQL instance
After the application instance and the PostgreSQL instance are created, the application instance can't access the PostgreSQL instance directly. Use the following steps to enable the app to connect to the PostgreSQL instance.
Use the following command to get the PostgreSQL instance's fully qualified domain name:
The Deploy to Azure button in the previous section launches an Azure portal experience that includes application deployment, so nothing else is needed.
The following list describes the command interactions:
Select child modules to configure: Select the module to configure, then enter the number of the SimpleTodo Web module.
OAuth2 login: You need to authorize the sign in to Azure based on the OAuth2 protocol.
Select subscription: Select the subscription list number of the Azure Spring Apps instance you created, which defaults to the first subscription in the list. If you use the default number, press Enter directly.
Use existing Azure Spring Apps in Azure: Press y to use the existing Azure Spring Apps instance.
Select Azure Spring Apps for deployment: Select the number of the Azure Spring Apps instance you created. If you use the default number, press Enter directly.
Expose public access for this app: Press y.
Confirm to save all the above configurations: Press y. If you press n, the configuration isn't saved in the POM files.
Use the following command to deploy the app:
./mvnw azure-spring-apps:deploy
The following list describes the command interaction:
OAuth2 login: You need to authorize the sign in to Azure based on the OAuth2 protocol.
After the command is executed, you can see from the following log messages that the deployment was successful:
[INFO] Deployment Status: Running
[INFO] InstanceName:simple-todo-web-default-15-xxxxxxxxx-xxxxx Status:Running Reason:null DiscoverStatus:N/A
[INFO] Getting public url of app(simple-todo-web)...
[INFO] Application url: https://<your-Azure-Spring-Apps-instance-name>-simple-todo-web.azuremicroservices.io
The output Application url is the endpoint to access the todo application.
Now that the cloud environment is prepared, the application is ready to deploy. Use the following command to deploy the app:
az spring app deploy \
--service ${AZURE_SPRING_APPS_NAME} \
--name ${APP_NAME} \
--artifact-path web/target/simple-todo-web.jar
The Deploy to Azure button in the next section launches an Azure portal experience that downloads a JAR package from the ASA-Samples-Web-Application releases page on GitHub. No local preparation steps are needed.
Although you use the Azure portal in later steps, you must use the Bash command line to prepare the project locally. Use the following steps to clone and run the app locally:
Use the following command to clone the sample project from GitHub:
The following list describes the command interaction:
Enter a new environment name: Provide an environment name, which is used as a suffix for the resource group created to hold all the Azure resources. This name should be unique within your Azure subscription.
The console outputs messages similar to the following example:
Initializing a new project (azd init)
(✓) Done: Initialized git repository
(✓) Done: Downloading template code to: <your-local-path>
Enter a new environment name: <your-env-name>
SUCCESS: New project initialized!
You can view the template code in your directory: <your-local-path>
Learn more about running 3rd party code on our DevHub: https://aka.ms/azd-third-party-code-notice
3. Prepare the cloud environment
The main resources required to run this sample are an Azure Spring Apps instance and an Azure Database for PostgreSQL instance. This section provides the steps to create these resources.
This section uses a Deploy to Azure button to launch a deployment experience in the Azure portal. This experience uses an ARM template to create Azure resources.
3.1. Sign in to the Azure portal
Go to the Azure portal and enter your credentials to sign in to the portal. The default view is your service dashboard.
3.2. Create Azure resources
Use the following steps to create all the Azure resources that the app depends on:
Select the following Deploy to Azure button to launch the deployment experience in the Azure portal:
Fill out the form on the Basics tab. Use the following table as a guide for completing the form:
Setting
Suggested value
Description
Subscription
Your subscription name.
The Azure subscription that you want to use for your server. If you have multiple subscriptions, choose the subscription in which you'd like to be billed for the resource.
Resource group
myresourcegroup
A new resource group name or an existing one from your subscription.
Region
The region closest to your users.
The region is used to create the resource group.
Postgre SQL Admin Password
N/A
The password for the PostgreSQL Server administrator.
Postgre SQL User Password
N/A
The password for the PostgreSQL application user, which is used in the application.
Select Review and Create to review your selections. Then, select Create to deploy the app to Azure Spring Apps.
On the toolbar, select the Notifications icon (a bell) to monitor the deployment process. After the deployment finishes, you can select Pin to dashboard, which creates a tile for this service on your Azure portal dashboard as a shortcut to the service's Overview page. Select Go to resource to open the service's Overview page.
Use the following steps to create an Azure Spring Apps instance and an Azure Database for PostgreSQL instance:
3.1. Sign in to the Azure portal
Go to the Azure portal, enter your credentials, and sign in to the portal. The default view is your service dashboard.
3.2. Create an Azure Spring Apps instance
Use the following steps to create a service instance:
Select Create a resource in the corner of the portal.
Select Compute > Azure Spring Apps.
Fill out the form on the Basics tab. Use the following table as a guide for completing the form:
Setting
Suggested value
Description
Subscription
Your subscription name.
The Azure subscription that you want to use for your server. If you have multiple subscriptions, choose the subscription in which you'd like to be billed for the resource.
Resource group
myresourcegroup
A new resource group name or an existing one from your subscription.
Name
myasa
A unique name that identifies your Azure Spring Apps service. The name must be between 4 and 32 characters long and can contain only lowercase letters, numbers, and hyphens. The first character of the service name must be a letter and the last character must be either a letter or a number.
Plan
Standard consumption & dedicated (preview)
The pricing plan determines the resource and cost associated with your instance.
Region
The region closest to your users.
The location that is closest to your users.
Container Apps Environment
myacaenv
The environment is a secure boundary around one or more container apps that can communicate with each other and share a virtual network, logging, and Dapr configuration.
(Optional) Fill out the Basics tab with the following information to create Container Apps Environment:
Environment name: myacaenv
Plan: Consumption
Zone redundancy: Disabled
Then, select Create to create the Container Apps Environment.
Select Review and Create to review your selections. Then, select Create to provision the Azure Spring Apps instance.
On the toolbar, select the Notifications icon (a bell) to monitor the deployment process. After the deployment finishes, you can select Pin to dashboard, which creates a tile for this service on your Azure portal dashboard as a shortcut to the service's Overview page. Select Go to resource to open the service's Overview page.
3.3. Prepare the PostgreSQL instance
Use the following steps to create an Azure Database for PostgreSQL server:
In the Azure portal, select Create a resource.
Select Databases > Azure Database for PostgreSQL Flexible Server.
Fill out the Basics tab with the following information:
Server name: my-demo-pgsql
Region: East US
PostgreSQL version: 14
Workload type: Development
Enable high availability: unselected
Authentication method: PostgreSQL authentication only
Admin username: myadmin
Password and Confirm password: Enter a password.
Configure the Networking tab using the following information:
Connectivity method: Public access (allowed IP addresses)
Allow public access from any Azure service within Azure to this server: selected
Select Review + create to review your selections, then select Create to provision the server. This operation might take a few minutes.
Go to your PostgreSQL server in the Azure portal.
Select Databases from the navigation menu to create a database - for example, Todo.
3.4. Connect app instance to PostgreSQL instance
Use the following steps to connect your service instances:
Go to your Azure Spring Apps instance in the Azure portal.
From the navigation pane, open Apps and then select Create App.
On the Create App page, for the app name, use simple-todo-web and then select Use quick start sample app to create the app.
Select Create to finish creating the app and then select the app to view its details.
Select Configuration from the navigation pane and then configure the following properties on the Environment variables tab:
Use the following steps to create an Azure Spring Apps instance and an Azure Database for PostgreSQL instance:
Use the following command to sign in to Azure with OAuth2. Ignore this step if you've already signed in.
azd auth login
The console outputs messages similar to the following example:
Logged in to Azure.
Use the following command to provision the template's infrastructure to Azure:
azd provision
The following list describes the command interactions:
Please select an Azure Subscription to use: Use arrows to move, type to filter, then press ENTER.
Please select an Azure location to use: Use arrows to move, type to filter, then press ENTER.
The console outputs messages similar to the following example:
SUCCESS: Your application was provisioned in Azure in xx minutes xx seconds.
You can view the resources created under the resource group rg-<your-environment-name> in Azure Portal:
https://portal.azure.com/#@/resource/subscriptions/<your-subscription-id>/resourceGroups/rg-<your-environment-name>/overview
Note
This command may take a while to complete. You see a progress indicator as it provisions Azure resources.
The Deploy to Azure button in the previous section launches an Azure portal experience that includes application deployment, so nothing else is needed.
The following list describes the command interactions:
Select child modules to configure: Select the module to configure, then enter the number of the SimpleTodo Web module.
OAuth2 login: You need to authorize the sign in to Azure based on the OAuth2 protocol.
Select subscription: Select the subscription list number of the Azure Spring Apps instance you created, which defaults to the first subscription in the list. If you use the default number, press Enter directly.
Use existing Azure Spring Apps in Azure: Press y to use the existing Azure Spring Apps instance.
Select Azure Spring Apps for deployment: Select the number of the Azure Spring Apps instance you created. If you use the default number, press Enter directly.
Expose public access for this app: Press y.
Confirm to save all the above configurations: Press y. If you press n, the configuration isn't saved in the POM files.
Use the following command to deploy the app:
./mvnw azure-spring-apps:deploy
The following list describes the command interaction:
OAuth2 login: You need to authorize the sign in to Azure based on the OAuth2 protocol.
After the command is executed, you can see from the following log messages that the deployment was successful:
[INFO] Start updating app(simple-todo-web)...
[INFO] App(simple-todo-web) is successfully updated.
[INFO] Starting Spring App after deploying artifacts...
[INFO] Deployment Status: Running
[INFO] InstanceName:simple-todo-web--default-xxxxxxx-xxxxxxxxx-xxxxx Status:Running Reason:null DiscoverStatus:NONE
[INFO] Getting public url of app(simple-todo-web)...
[INFO] Application url: https://simple-todo-web.<unique-identifier>.<region-name>.azurecontainerapps.io
The output Application url is the endpoint to access the todo application.
You can now deploy the app to Azure Spring Apps. Use the following steps to package the app, provision the Azure resources required by the web application, and then deploy to Azure Spring Apps:
Use the following command to package a deployable copy of your application:
azd package
The console outputs messages similar to the following example:
SUCCESS: Your application was packaged for Azure in xx seconds.
Use the following command to deploy the application code to those newly provisioned resources:
azd deploy
The console outputs messages similar to the following example:
Deploying services (azd deploy)
(✓) Done: Deploying service simple-todo-web
- Endpoint: https://simple-todo-web.xxx.<your-azure-location>.azurecontainerapps.io
SUCCESS: Your application was deployed to Azure in xx minutes xx seconds.
You can view the resources created under the resource group rg-<your-environment-name> in Azure Portal:
https://portal.azure.com/#@/resource/subscriptions/<your-subscription-id>/resourceGroups/rg-<your-environment-name>/overview
The output Endpoint is the endpoint to access the todo application.
Note
You can also use azd up to combine the previous three commands: azd provision (provisions Azure resources), azd package (packages a deployable copy of your application), and azd deploy (deploys application code). For more information, see Azure-Samples/ASA-Samples-Web-Application.
The Deploy to Azure button in the next section launches an Azure portal experience that downloads a JAR package from the ASA-Samples-Web-Application releases page on GitHub. No local preparation steps are needed.
Although you use the Azure portal in later steps, you must use the Bash command line to prepare the project locally. Use the following steps to clone and run the app locally:
Use the following command to clone the sample project from GitHub:
The following list describes the command interaction:
Enter a new environment name: Provide an environment name, which is used as a suffix for the resource group created to hold all the Azure resources. This name should be unique within your Azure subscription.
The console outputs messages similar to the following example:
Initializing a new project (azd init)
(✓) Done: Initialized git repository
(✓) Done: Downloading template code to: <your-local-path>
Please enter a new environment name: <your-env-name>
SUCCESS: New project initialized!
You can view the template code in your directory: <your-local-path>
Learn more about running 3rd party code on our DevHub: https://aka.ms/azd-third-party-code-notice
3. Prepare the cloud environment
The main resources required to run this sample are an Azure Spring Apps instance and an Azure Database for PostgreSQL instance. This section provides the steps to create these resources.
This section uses a Deploy to Azure button to launch a deployment experience in the Azure portal. This experience uses an ARM template to create Azure resources.
3.1. Sign in to the Azure portal
Go to the Azure portal and enter your credentials to sign in to the portal. The default view is your service dashboard.
3.2. Create Azure resources
Use the following steps to create all the Azure resources that the app depends on:
Select the following Deploy to Azure button to launch the deployment experience in the Azure portal:
Fill out the form on the Basics tab. Use the following table as a guide for completing the form:
Setting
Suggested value
Description
Subscription
Your subscription name.
The Azure subscription that you want to use for your server. If you have multiple subscriptions, choose the subscription in which you'd like to be billed for the resource.
Resource group
myresourcegroup
A new resource group name or an existing one from your subscription.
Region
The region closest to your users.
The region is used to create the resource group.
Postgre SQL Admin Password
N/A
The password for the PostgreSQL Server administrator.
Postgre SQL User Password
N/A
The password for the PostgreSQL application user, which is used in the application.
Select Review and Create to review your selections. Then select Create to deploy the app to Azure Spring Apps.
On the toolbar, select the Notifications icon (a bell) to monitor the deployment process. After the deployment finishes, you can select Pin to dashboard, which creates a tile for this service on your Azure portal dashboard as a shortcut to the service's Overview page. Select Go to resource to open the service's Overview page.
Use the following steps to create an Azure Spring Apps instance and an Azure Database for PostgreSQL instance:
3.1. Sign in to the Azure portal
Go to the Azure portal and enter your credentials to sign in to the portal. The default view is your service dashboard.
3.2. Create an Azure Spring Apps instance
Use the following steps to create a service instance:
Select Create a resource in the corner of the portal.
Select Compute > Azure Spring Apps.
Fill out the form on the Basics tab. Use the following table as a guide for completing the form:
Setting
Suggested value
Description
Subscription
Your subscription name.
The Azure subscription that you want to use for your server. If you have multiple subscriptions, choose the subscription in which you'd like to be billed for the resource.
Resource group
myresourcegroup
A new resource group name or an existing one from your subscription.
Name
myasa
A unique name that identifies your Azure Spring Apps service. The name must be between 4 and 32 characters long and can contain only lowercase letters, numbers, and hyphens. The first character of the service name must be a letter and the last character must be either a letter or a number.
Plan
Basic
The pricing plan determines the resource and cost associated with your instance.
Region
The region closest to your users.
The location that is closest to your users.
Zone Redundant
Unselected
Whether to create your Azure Spring Apps service in an Azure availability zone. Currently, this feature is supported only in some regions.
Select Review and Create to review your selections. Then, select Create to provision the Azure Spring Apps instance.
On the toolbar, select the Notifications icon (a bell) to monitor the deployment process. After the deployment finishes, you can select Pin to dashboard, which creates a tile for this service on your Azure portal dashboard as a shortcut to the service's Overview page. Select Go to resource to open the service's Overview page.
3.3. Prepare the PostgreSQL instance
Use the following steps to create an Azure Database for PostgreSQL server:
In the Azure portal, select Create a resource.
Select Databases > Azure Database for PostgreSQL Flexible Server.
Fill out the Basics tab with the following information:
Server name: my-demo-pgsql
Region: East US
PostgreSQL version: 14
Workload type: Development
Enable high availability: unselected
Authentication method: PostgreSQL authentication only
Admin username: myadmin
Password and Confirm password: Enter a password.
Configure the Networking tab using the following information:
Connectivity method: Public access (allowed IP addresses)
Allow public access from any Azure service within Azure to this server: selected
Select Review + create to review your selections, then select Create to provision the server. This operation might take a few minutes.
Go to your PostgreSQL server in the Azure portal.
Select Databases from the navigation menu to create a database - for example, Todo.
3.4. Connect app instance to PostgreSQL instance
Use the following steps to connect your service instances:
Go to your Azure Spring Apps instance in the Azure portal.
From the navigation pane, open the Apps pane and select Create App.
On the Create App page, for the app name, use simple-todo-web and for the runtime platform, select Java 17.
Select Create to finish the app creation and select the app to view details.
Select Service Connector from the navigation pane and then select Create to create a new service connection.
Fill out the Basics tab with the following information:
Service type: DB for PostgreSQL flexible server
Connection name: Populated with an automatically generated name that you can modify.
Subscription: Select your subscription.
PostgreSQL flexible server: my-demo-pgsql
PostgreSQL database: Select the database you created.
Client type: SpringBoot
Configure the Next: Authentication tab with the following information:
Select the authentication type you'd like to use between your compute service and target service.: Select Connection string.
Continue with...: Select Database credentials.
Username: myadmin
Password: Enter your password.
Select Next: Networking. Use the default option Configure firewall rules to enable access to target service..
Select Next: Review and Create to review your selections and then select Create to create the connection.
Use the following steps to create an Azure Spring Apps instance and an Azure Database for PostgreSQL instance:
Use the following command to log in Azure with OAuth2. Ignore this step if you've already logged in.
azd auth login
The console outputs messages similar to the following example:
Logged in to Azure.
Use the following command to set the template with the standard plan:
azd env set PLAN standard
Use the following command to provision the template's infrastructure to Azure:
azd provision
The following list describes the command interactions:
Please select an Azure Subscription to use: Use arrows to move, type to filter, then press ENTER.
Please select an Azure location to use: Use arrows to move, type to filter, then press ENTER.
The console outputs messages similar to the following example:
SUCCESS: Your application was provisioned in Azure in xx minutes xx seconds.
You can view the resources created under the resource group rg-<your-environment-name> in Azure Portal:
https://portal.azure.com/#@/resource/subscriptions/<your-subscription-id>/resourceGroups/rg-<your-environment-name>/overview
Note
This command may take a while to complete. You see a progress indicator as it provisions Azure resources.
The Deploy to Azure button in the previous section launches an Azure portal experience that includes application deployment, so nothing else is needed.
The following list describes the command interactions:
Select child modules to configure: Select the module to configure, then enter the number of the SimpleTodo Web module.
OAuth2 login: Authorize the sign in to Azure based on the OAuth2 protocol.
Select subscription: Select the subscription list number of the Azure Spring Apps instance you created, which defaults to the first subscription in the list. If you use the default number, press ENTER directly.
Select Azure Spring Apps: Select the number of the Azure Spring Apps instance you created. If you use the default number, press ENTER directly.
Expose public access for this app?: Press y.
Confirm to save all the above configurations (Y/n): Press y. If you press n, the configuration isn't saved in the POM files.
Use the following command to deploy the app:
./mvnw azure-spring-apps:deploy
The following list describes the command interaction:
OAuth2 login: You need to authorize the sign in to Azure based on the OAuth2 protocol.
After the command is executed, you can see from the following log messages that the deployment was successful:
[INFO] Deployment(default) is successfully created
[INFO] Starting Spring App after deploying artifacts...
[INFO] Deployment Status: Running
[INFO] InstanceName:simple-todo-web-default-x-xxxxxxxxxx-xxxxx Status:Running Reason:null DiscoverStatus:UNREGISTERED
[INFO] InstanceName:simple-todo-web-default-x-xxxxxxxxx-xxxxx Status:Terminating Reason:null DiscoverStatus:UNREGISTERED
[INFO] Getting public url of app(simple-todo-web)...
[INFO] Application url: https://<your-Azure-Spring-Apps-instance-name>-simple-todo-web.azuremicroservices.io
The output Application url is the endpoint to access the todo application.
You can now deploy the app to Azure Spring Apps. Use the following steps to package the app, provision the Azure resources required by the web application, and then deploy to Azure Spring Apps:
Use the following command to package a deployable copy of your application:
azd package
The console outputs messages similar to the following example:
SUCCESS: Your application was packaged for Azure in xx seconds.
Use the following command to deploy the application code to those newly provisioned resources:
azd deploy
The console outputs messages similar to the following example:
Deploying services (azd deploy)
(✓) Done: Deploying service simple-todo-web
- Endpoint: https://<your-Azure-Spring-Apps-instance-name>-simple-todo-web.azuremicroservices.io/
SUCCESS: Your application was deployed to Azure in xx minutes xx seconds.
You can view the resources created under the resource group rg-<your-environment-name> in Azure Portal:
https://portal.azure.com/#@/resource/subscriptions/<your-subscription-id>/resourceGroups/rg-<your-environment-name>/overview
The output Endpoint is the endpoint to access the todo application.
Note
You can also use azd up to combine the previous three commands: azd package (packages a deployable copy of your application), azd provision (provisions Azure resources), and azd deploy (deploys application code). For more information, see Azure-Samples/ASA-Samples-Web-Application.
5. Validate the web app
Now you can access the deployed app to see whether it works.
After the deployment finishes, you can find the application URL from the deployment outputs:
Access the application with the output application URL. The page should appear as you saw in localhost.
Check the details for each resource deployment, which are useful for investigating any deployment issues.
Access the application with the output application URL. The page should appear as you saw in localhost.
Use the following steps to validate:
After the deployment finishes, you can access the app with this URL: https://${AZURE_SPRING_APPS_NAME}-${APP_NAME}.azuremicroservices.io/. The page should appear as you saw in localhost.
To check the app's log to investigate any deployment issue, use the following command:
az spring app logs \
--service ${AZURE_SPRING_APPS_NAME} \
--name ${APP_NAME}
After the deployment finishes, find the application URL from the deployment outputs:
Access the application URL. The page should appear as you saw in localhost.
Check the details for each resource deployment, which are useful for investigating any deployment issues.
Access the application with the output application URL. The page should appear as you saw in localhost.
Access the application with the output endpoint. The page should appear as you saw in localhost.
6. Clean up resources
Be sure to delete the resources you created in this article when you no longer need them. You can delete the Azure resource group, which includes all the resources in the resource group.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback.