Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploying a Spring Boot app to Azure #55

Closed
Hanope opened this issue Nov 12, 2018 · 0 comments
Closed

Deploying a Spring Boot app to Azure #55

Hanope opened this issue Nov 12, 2018 · 0 comments
Labels
complete 번역완료 translation 번역 작업

Comments

@Hanope
Copy link
Owner

Hanope commented Nov 12, 2018

Deploying a Spring Boot app to Azure

This article walks you through deploying an application to Azure.

What you’ll build

You’ll clone a sample Spring Boot application from GitHub and then use Maven to deploy it to Azure.

What you’ll need

The following prerequisites are required in order to follow the steps in this article:

Create a sample Spring Boot web app

In this section, you will clone an already written Spring Boot application and test it locally:

  1. Open a terminal window.

  2. Create a local directory to hold your Spring Boot application by typing mkdir SpringBoot

  3. Change to that directory by typing cd SpringBoot.

  4. Clone the Spring Boot Getting Started sample project into the directory you created by typing git clone https://github.com/microsoft/gs-spring-boot

  5. Change to the directory of the completed project by typing cd gs-spring-boot/complete

  6. Build the JAR file using Maven by typing ./mvnw clean package

  7. When the web app has been created, start it by typing ./mvnw spring-boot:run

  8. Test it locally by either visiting http://localhost:8080 or typing curl http://localhost:8080 from another terminal window.

  9. You should see the following message displayed: Greetings from Spring Boot!

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.

  1. Open a terminal window.

  2. Sign into your Azure account with the Azure CLI by typing az login

  3. Create 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": "uuuuuuuu",
        "name": "http://uuuuuuuu",
        "password": "pppppppp",
        "tenant": "tttttttt-tttt-tttt-tttt-tttttttttttt"
    }

Note the values as they are to be used further down.

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.

  1. Open your Maven settings.xml file in a text editor (usually found at either /etc/maven/settings.xml or $HOME/.m2/settings.xml).

  2. Add your Azure service principal settings from the previous section of this tutorial to the <servers> collection in the settings.xml file as shown below:

<servers>
   <server>
     <id>azure-auth</id>
      <configuration>
         <client>aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa</client>
         <tenant>tttttttt-tttt-tttt-tttt-tttttttttttt</tenant>
         <key>pppppppp</key>
         <environment>AZURE</environment>
      </configuration>
   </server>
</servers>
  1. Save and close the settings.xml file.

See Maven Plugin for Azure Web Apps for documentation.

Build and deploy your app to Azure

Once you have configured all of the settings in the preceding sections, you are ready to deploy your web app to Azure.

From the terminal window, deploy your web app to Azure with Maven by typing ./mvnw 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:


Click on the application. From there, the publicly-facing URL for your web app will be listed in the Overview section:


You can click on this link to visit the Spring Boot application and interact with it.

Summary

Congratulations! You built and deployed a Spring Boot app to Azure.

See also

Additional information about using Spring with Azure is available here:

@Hanope Hanope added the translation 번역 작업 label Nov 12, 2018
Hanope added a commit that referenced this issue Nov 16, 2018
#55 Deploying a Spring Boot app to Azure 번역 완료
@Hanope Hanope added the complete 번역완료 label Nov 16, 2018
@Hanope Hanope closed this as completed Nov 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complete 번역완료 translation 번역 작업
Projects
None yet
Development

No branches or pull requests

1 participant