In build.gradle update reference to local maven repo. Then run
# Windows
gradlew.bat publishToMavenLocal
# Linux/macOS
./gradlew publishToMavenLocal
Azure WebApp plugin
plugins {
id "lenala.azure.azurewebapp" version "1.0.1"
}
Common settings
Name
Required
Value
resourceGroup
true
Azure resource group to create Web App
appName
true
Web App name
region
false
Azure region. Optional, default is WEST_US2
appServicePlanResourceGroup
false
Specifies the resource group of the existing App Service Plan when you do not want to create a new one. If this setting is not specified, plugin will use the value defined in resourceGroup
appServicePlanName
false
Specifies the name of the existing App Service Plan when you do not want to create a new one.
stopAppDuringDeployment
false
Specifies whether to stop Web App during deployment. Optional, default is false
appService
true
Block that specifies AppService settings
type
true
Type of the AppService, one of {'linux','windows','docker'}
runtimeStack
false
Supported are {'TOMCAT 8.5-jre8', 'TOMCAT 9.0-jre8', 'WILDFLY" 14-jre8', 'jre8'}
javaWebContainer
false
One of WebContainer values, default is TOMCAT_8_5_NEWEST
javaVersion
false
For App Service on Windows, supported versions are: {1.7, 1.7.0_51, 1.7.0_71, 1.8, 1.8.0_25, 1.8.0_60, 1.8.0_73, 1.8.0_111, 1.8.0_92, 1.8.0_102, 1.8.0_144}
imageName
false
startUpFile
false
serverId
false
username
false
password
false
registryUrl
false
pricingTier
false
Specifies the pricing tier for your Web App; the default value is S1.
authentication
true
Bloack that specifies authentication with Azure
type
Authentication type, one of {FILE,PROPERTIES,AZURECLI}
Deployment type - one of {FTP, WAR, JAR, ZIP, NONE}. Optional, default value is WAR.
warFile
false
Target war file to deploy. Not used for Web Apps for containers. Optional, if not specified, default war file output produced by 'war' plugin will be used.
jarFile
false
Target jar file to deploy. Not used for Web Apps for containers. Optional, if not specified, default jar file output produced by 'bootJar' plugin will be used.
deploymentSlot
false
Deployment slot name to use. For springboot1337/deploy the name you should enter is "deploy"
contextPath
false
Url path
These types of deployment are supported:
Web App on Windows
Deploy WAR
appService block should be specified, with the values:
Web Container. Optional, default is newest Tomcat 8.5.
azureWebApp {
resourceGroup = "${System.env.WEBAPP_RESOURCE_GROUP}"
appName = "${System.env.WEBAPP_NAME}"
pricingTier = "S2"
region = "southcentralus"
appService = {
type = 'windows'
javaWebContainer = "tomcat 8.5"
javaVersion = "1.8.0_102"
}
authentication = {
type = "file"
file = "<path_to_auth_file>"
}
deployment = {
type = "war"
// if 'warFile' is not specified, default output of the 'war' plugin will be used
// warFile = '<path_to_war_file>'
contextPath = 'todoapp' // Url path. Optional, if not specified Web App will be deployed to root. Works for WAR deployment type only.
}
}
Deploy JAR
appService block should be specified, with the values:
In samples/todo-app-on-azure folder, update reference to local maven repo, appName and Azure Container Registry url and credentials. Follow this tutorial to get started with Azure Container Registry.
In gradle.properties, set your container registry serverId, serverUsername, and serverPassword.
To push the Docker image, you'll need Docker running, then execute the dockerPushImage task:
# Windows
gradlew.bat dockerPushImage
# Linux/macOS
./gradlew dockerPushImage
Create a new CosmosDB instance and set your CosmosDB credentials in src/main/resources/application.properties.
Configure azurewebapp in build.gradle with valid values for resourceGroup, appName, pricingTier, and authFile (see the section on Azure Authentication settings).
Then deploy the ToDo web application to a Azure Container instance, you must specify the azureWebappDeploy task:
# Windows
gradlew.bat azureWebappDeploy
# Linux/macOS
./gradlew azureWebappDeploy
containerSettings block should be specified.
Deployment from Private Container Registry (Azure Container Registry)
To authenticate with Azure, device login can be used. To enable that, you need to sign in with Azure CLI first.
Alternatively, authentication file can be used. The authentication file, referenced as "my.azureauth" in the example,
contains the information of a service principal. You can generate this file using Azure CLI 2.0 through the following command.
Make sure you selected your subscription by az account set --subscription and you have the privileges to create service principals.
az ad sp create-for-rbac --sdk-auth > my.azureauth
请发表评论