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

support choosing region when creating new function app project #5

Merged
merged 3 commits into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions azure-functions-archetype/README.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 2 additions & 1 deletion azure-functions-archetype/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down