适用于Azure Web Apps的Maven插件不工作 [英] Maven Plugin for Azure Web Apps "<appServicePlanName>" not working

查看:76
本文介绍了适用于Azure Web Apps的Maven插件不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用最新的Maven Azure Functions原型创建新项目

Created new project using latest Maven Azure Functions Archetype

mvn archetype:generate -DarchetypeGroupId=com.microsoft.azure -DarchetypeArtifactId=azure-functions-archetype -DarchetypeVersion=1.11

我正在pom文件中使用以下标记.

I am using following tag in pom file.

<appServicePlanName>XXX2Plan</appServicePlanName>

文档说::当您不想创建新的应用服务计划时,请指定其名称.

Doc says : Specifies the name of the existing App Service Plan when you do not want to create a new one.

但是在部署其创建的使用现有服务的新APP服务计划后,我想知道是否有人解决了该问题?

but after deployment its creating new APP SERVICE PLAN insted of using existing one, i am wonder if anyone solved it ?

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.khan.vaquar</groupId>
    <artifactId>vaquar-khan-demo-azure-java-function</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Azure Java Functions</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <azure.functions.maven.plugin.version>1.0.0-beta-2</azure.functions.maven.plugin.version>
        <azure.functions.java.library.version>1.0.0-beta-4</azure.functions.java.library.version>
        <functionAppName>vaquar-azure-java-function-demo</functionAppName>
        <functionAppRegion>canadaeast</functionAppRegion>
        <stagingDirectory>${project.build.directory}/azure-functions/${functionAppName}</stagingDirectory>
        <functionResourceGroup>XXXXXX</functionResourceGroup>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-core</artifactId>
                <version>2.4.0</version>
            </dependency>
            <dependency>
                <groupId>com.microsoft.azure.functions</groupId>
                <artifactId>azure-functions-java-library</artifactId>
                <version>${azure.functions.java.library.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.microsoft.azure.functions</groupId>
            <artifactId>azure-functions-java-library</artifactId>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.microsoft.azure</groupId>
                    <artifactId>azure-functions-maven-plugin</artifactId>
                    <version>${azure.functions.maven.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>com.microsoft.azure</groupId>
                <artifactId>azure-functions-maven-plugin</artifactId>
                <configuration>
                    <resourceGroup>${functionResourceGroup}</resourceGroup>
                    <appServicePlanName>XXX2Plan</appServicePlanName>
                    <appName>${functionAppName}</appName>
                    <region>${functionAppRegion}</region>
                    <appSettings>
                        <property>
                            <name>FUNCTIONS_EXTENSION_VERSION</name>
                            <value>beta</value>
                        </property>
                    </appSettings>
                </configuration>
                <executions>
                    <execution>
                        <id>package-functions</id>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <overwrite>true</overwrite>
                            <outputDirectory>${stagingDirectory}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}</directory>
                                    <includes>
                                        <include>host.json</include>
                                        <include>local.settings.json</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${stagingDirectory}/lib</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                            <includeScope>runtime</includeScope>
                            <excludeArtifactIds>azure-functions-java-library</excludeArtifactIds>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

https ://docs.microsoft.com/zh-CN/java/api/overview/azure/maven/azure-webapp-maven-plugin/readme

解决方法:首先手动创建功能,然后使用maven进行部署 安装了允许Maven为您创建功能.

Workaround: First manually create function and then deploy using maven insted of allow maven to create function for you.

推荐答案

您提到的文档适用于azure Web应用程序,而

Document you mentioned is for azure web app, while one for functions says only following properties are supported, including resourceGroup/appName/region/pricingTier/appSettings/deploymentType.

我们可以看到appServicePlanName的代码实现/main/java/com/microsoft/azure/maven/function/AbstractFunctionMojo.java"rel =" nofollow noreferrer>功能插件,而该插件在

And we can see there's no code implementation about appServicePlanName in function plugin, while it is implemented in web app plugin.

因此,我认为目前不支持使用maven插件将功能应用程序部署到现有的应用程序服务计划中.

So I assume for now it's not supported to deploy function app to existing app service plan using maven plugin.

解决方法是先在门户上创建新的功能应用程序,然后使用mvn插件将功能部署到该应用程序.

And workaround is to create new function app on portal first, then deploy functions to this app with mvn plugin.

更新

确实不受支持,请参见此问题.

Not supported indeed, see this issue.

Update2

1.0.0-beta-3 azure-functions-maven-plugin支持此功能.

This feature has been supported from 1.0.0-beta-3 azure-functions-maven-plugin.

需要在<properties>下添加<appServicePlanName>existingplanname</appServicePlanName>.

这篇关于适用于Azure Web Apps的Maven插件不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆