Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Azure-Samples/app-service-wildfly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

page_type languages products description urlFragment
sample
java
app service
How to deploy Wildfly applications onto App Service
update-this-to-unique-url-stub

Official Microsoft Sample

This repository shows how to build and run your own Wildfly container image on Azure App Service. Once the container is running on App Service, you can deploy your WAR applications onto the container using App Service's REST APIs for publishing.

Contents

Outline the file contents of the repository.

File/folder Description
tmp/ Files that are copied to the container image during build
sample/ A sample application to build and deploy onto the image
.gitignore Define what to ignore at commit time.
CHANGELOG.md List of changes to the sample.
CONTRIBUTING.md Guidelines for contributing to the sample.
README.md This README file.
LICENSE The license for the sample.

Prerequisites

You should have the following development tools installed on your local machine.

You will also need accounts for the following services

Running the sample

Build and test locally

Before deploying to App Service, build and run the image locally.

docker build -t wildfly .
docker run -p 8080:80 wildfly 

Open a browser to http://127.0.0.1:8080/ and index.jsp will be rendered by Wildfly.

Push to a container registry

Now that the container works locally, we will push the container to our registry so our Web App for Containers can pull it in the next step. First, create a container registry on DockerHub or Azure Container Registry (ACR) by following either of the guides below.

Once your registry is created, log into the registry. The commands will differ slightly for DockerHub and ACR. If your registry is on DockerHub, log in with docker using the command below. Enter your username and password when prompted.

docker login

If your registry is on ACR, log in with the Azure CLI using the command below.

az acr login --name <your-registry-name>

Once you are logged in, push the image to your registry using docker. This command is the same for both DockerHub and ACR registries.

docker push <your-registry-name>/wildfly

Deploy the container to Web App for Containers

If you have not already, create a Web App for Container using the Azure CLI. This command will create your Web App and configure it to use your Wildfly image. If you do not already have an App Service Plan, you can use az appservice plan create to create one.

az webapp create --name <your-desired-name> --plan <your-app-service-plan> -g <your-resource-group> -i <your-registry-name>/wildfly

Once the Web App has been deployed, open your browser to https://<your-desired-name>.azurewebsites.net/. You will see index.jsp.

Example showing the JSP

Deploy an application on Wildfly

Now that the Wildfly runtime is functioning on App Service, we will deploy a sample WAR application onto Wildfly. First, build the application using Maven.

cd sample/agoncal-application-petstore-ee7
mvn clean install -DskipTests

Before deploying the built application, we need to configure our Web App to use the service's shared file storage. This will allow us to deploy artifacts using App Service's REST APIs. Your Web App already has an application setting named WEBSITES_ENABLE_APP_SERVICE_STORAGE with a value of false. Using the Azure Portal or CLI, change this setting's value to true.

Next, deploy the WAR file using App Service's REST APIs for deployment. For WAR applications, use /api/wardeploy/. The username and password for the following command are from your Web App's publish profile.

curl -X Post -u <username> --data-binary @"target/applicationPetstore.war" https://<your-app-name>.scm.azurewebsites.net/api/wardeploy

If you are using PowerShell, there is a Azure commandlet for WAR deploy.

Publish-AzWebapp -ResourceGroupName <group-name> -Name <app-name> -ArchivePath "target\applicationPetstore.war"

Once the deployment completes, browse to your application and you will see the Pet Store application has replaced the default index.jsp from earlier.

Pet Store application running on the Wildfly image

Next steps

Congratulations! You now have a Wildfly image in your container registry and running on App Service. Finally, you deployed a WAR application to the image.

Deploy your own WAR application

In this sample we deployed an example WAR application. You will likely want to deploy your own apps onto Wildfly. To do so, you can use WAR deploy again with our own artifact.

SSH into the image

The Dockerfile has been configured to allow SSH using App Service's native APIs. To SSH into the container, go the Azure Portal and select your Web App. Under Development Tools select the option for SSH.

Build the application with the image

In this sample, we deployed our WAR application onto the running image using App Service's /api/wardeploy/ endpoint. Alternatively, you can modify your Dockerfile to build your app and copy the WAR file. This will couple the container image with the WAR application(s).

Change the Wildfly version

This sample uses Wildfly 14. You can use a different version of Wildfly by modifying the Dockerfile. See the Wildfly downloads site for a full list of available Wildfly versions.

Key concepts

Please see the pages below for more information on the technologies used.

Support

The base image in the sample Dockerfile uses a Azul Zulu Enterprise build of the OpenJDK. By using Azul Zulu, you get free maintenance updates and you can resolve support issues with Microsoft. This support does not extend to the Wildfly runtime. See the links below for more information about Azul Zulu Enterprise for Azure.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

About

How to deploy Wildfly applications on to App Service

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published