How to Deploy a Spring Boot application to Azure
Below are the tools required for this tutorial - MavenGit ClientAzure CLIJDKAzure Subscription Open a git bash terminal window.Clone the below sample project into the directory you created by typing git clone https://github.com/AnupBhagwat7/azure-demo-service.gitChange to the directory of the completed project by typing cd azure-demo-service Build the JAR file using Maven by typing mvn clean packageWhen the web app has been created, start it by typing mvn spring-boot:runTest it locally by visiting http://localhost:8080/api/hello You should see the following message displayed: Hello spring boot on azure!
REST API Response in Browser Create an Azure service principal In this section, you will create an Azure service principal that the Maven plugin uses when deploying your web app to Azure. Open a terminal window.Sign into your Azure account with the Azure CLI by typing az loginCreate an Azure service principal by typing az ad sp create-for-rbac --name "uuuuuuuu" --password "pppppppp" (uuuuuuuu is the user name and pppppppp is the password for the service principal). Azure should print out a JSON response resembling this: { "appId": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "displayName": "servicename", "name": "http://servicename", "password": "pass", "tenant": "tttttttt-tttt-tttt-tttt-tttttttttttt" } Configure Maven to use your Azure service principal In this section, you will configure Maven to authenticate using your Azure service principal for web app deployment. Open your Maven settings.xml file in a text editor (usually found at either /etc/maven/settings.xml or $HOME/.m2/settings.xml). Add your Azure service principal settings from the previous section of this tutorial to the collection in the settings.xml file as shown below: azure-auth aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa tttttttt-tttt-tttt-tttt-tttttttttttt pass AZURE Save and close the settings.xml file. You need to configure Maven Plugin for Azure Web Apps deployment. Below entry needs to be added in pom.xml - com.microsoft.azure azure-webapp-maven-plugin 1.1.0 Build and deploy your app to Azure Once you have configured all of the settings in the previous sections, you are ready to deploy your web app to Azure. From the git bash terminal window, deploy your web app to Azure with Maven by typing mvn azure-webapp:deploy Maven will deploy your web app to Azure using a plugin already in the build file of the sample project you cloned earlier. If the web app doesn’t already exist, it will be created. When your web app has been deployed, visit the Azure portal to manage it. It will be listed in App Services as show below: Web app will be listed in Azure portal App Services. Click on the application. From there, the publicly-facing URL for your web app will be listed in the Overview section. Determining the URL for your web app You can click on this link to visit the Spring Boot application and interact with it. Read the full article













