support choosing region when creating new function app project (#5)

This commit is contained in:
Kevin Zhao 2017-10-18 01:40:00 -05:00 коммит произвёл GitHub
Родитель 892a00282e
Коммит be57e77165
6 изменённых файлов: 45 добавлений и 6 удалений

Просмотреть файл

@ -4,9 +4,12 @@ This repo contains Maven Archetypes for Azure. The following table lists all exi
Archetype Artifact Id | Archetype Group Id | Maven Central Version
---|---|---
`azure-functions-archetype`|`com.microsoft.azure`|*Under Development*
`azure-functions-archetype`|`com.microsoft.azure`| [![Maven Central](https://img.shields.io/maven-central/v/com.microsoft.azure/azure-functions-archetype.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.microsoft.azure%22%20AND%20a%3A%22azure-functions-archetype%22)
# Contributing
### Reporting Issues and Feedback
If you encounter any bugs with the Maven Archetypes, please file an issue in the [Issues](https://github.com/microsoft/azure-maven-archetypes/issues) section of our GitHub repo.
#### 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

Просмотреть файл

@ -0,0 +1,27 @@
# Maven Archetypes for Azure Functions
[![Maven Central](https://img.shields.io/maven-central/v/com.microsoft.azure/azure-functions-archetype.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.microsoft.azure%22%20AND%20a%3A%22azure-functions-archetype%22)
This is the Maven Archetype for Azure Functions.
## Required Parameters
Like any other Maven Archetype, you are required to provide values for parameters `groupId`, `artifactId`, `version` and `package`.
On top of that, two extra parameters are required for Azure Functions Archetype as listed in below table. They both have default values.
You can use their default values or enter your own.
Parameter Name | Default Value | Description
---|---|---
`appName` | ${artifactId}-${timestamp} | Specifies the name of your Azure Function App, which will be used to package, run and deploy your project.
`appRegion` | westus | Specifies the region of your Azure Function App, which will be used to create new Function App in Azure.
## Usage
### Interactive Mode
Run below command to create projects for Azure Java Functions in interactive mode.
```cmd
mvn archetype:generate -DarchetypeGroupId=com.microsoft.azure -DarchetypeArtifactId=azure-functions-archetype
```
### Batch Mode
Refer to the example at [here](https://maven.apache.org/archetype/maven-archetype-plugin/examples/generate-batch.html) to generate project in batch mode.

Просмотреть файл

@ -6,11 +6,12 @@
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-functions-archetype</artifactId>
<version>1.0</version>
<version>1.1</version>
<packaging>jar</packaging>
<name>Maven Archetype for Azure Functions</name>
<description>Maven Archetype for Azure Functions</description>
<url>https://github.com/microsoft/azure-maven-archetypes</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

Просмотреть файл

@ -4,9 +4,16 @@
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
name="azure-functions-archetype" partial="true">
<requiredProperties>
<!-- Default value is ${artifactId}-${timestamp} -->
<requiredProperty key="appName">
<defaultValue>${artifactId.toLowerCase()}-${package.getClass().forName("java.time.LocalDateTime").getMethod("now").invoke(null).format($package.Class.forName("java.time.format.DateTimeFormatter").getMethod("ofPattern", $package.Class).invoke(null, "yyyyMMddHHmmssSSS"))}</defaultValue>
</requiredProperty>
<!-- This is a work around of issue at https://issues.apache.org/jira/browse/ARCHETYPE-308 -->
<!-- By using below expression, Maven Archetype will ask for user input with default value "westus" -->
<requiredProperty key="appRegion">
<defaultValue>${package.getClass().forName("java.lang.StringBuilder").getConstructor($package.getClass().forName("java.lang.String")).newInstance("westus").toString()}</defaultValue>
</requiredProperty>
</requiredProperties>
<fileSets>

Просмотреть файл

@ -16,6 +16,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<functionAppName>${appName}</functionAppName>
<functionAppRegion>${appRegion}</functionAppRegion>
</properties>
<dependencies>
@ -44,7 +45,7 @@
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-functions-maven-plugin</artifactId>
<version>0.1.4</version>
<version>0.1.5</version>
</plugin>
</plugins>
</pluginManagement>
@ -56,7 +57,7 @@
<configuration>
<resourceGroup>java-functions-group</resourceGroup>
<appName>${functionAppName}</appName>
<region>westus2</region>
<region>${functionAppRegion}</region>
<appSettings>
<property>
<name>FUNCTIONS_EXTENSION_VERSION</name>

Просмотреть файл

@ -6,7 +6,7 @@
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-maven-archetypes</artifactId>
<version>1.0</version>
<version>1.1</version>
<packaging>pom</packaging>
<name>Maven Archetypes for Azure</name>
<description>Maven Archetypes for Microsoft Azure services</description>