"不起作用-6ren"> "不起作用-使用最新的 Maven Azure Functions Archetype 创建新项目 mvn archetype:generate -DarchetypeGroupId=com.microsoft.-6ren">
gpt4 book ai didi

azure - Azure Web Apps 的 Maven 插件 ""不起作用

转载 作者:行者123 更新时间:2023-12-02 02:53:22 28 4
gpt4 key购买 nike

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

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

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

<appServicePlanName>XXX2Plan</appServicePlanName>

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

但是在部署后创建新的应用程序服务计划而不是使用现有的计划,我想知道是否有人解决了这个问题?

<?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://learn.microsoft.com/en-us/java/api/overview/azure/maven/azure-webapp-maven-plugin/readme

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

最佳答案

您提到的文档适用于azure web应用程序,而one for 函数表示仅支持以下属性,包括 resourceGroup/appName/region/pricingTier/appSettings/deploymentType .

我们可以看到没有关于 appServicePlanName 的代码实现在 function plugin ,而它是在 web app plugin 中实现的.

因此,我认为目前不支持使用 Maven 插件将函数应用程序部署到现有应用程序服务计划。

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

更新

确实不支持,请参阅this issue

更新2

此功能已由1.0.0-beta-3支持azure-functions-maven-plugin。

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

关于azure - Azure Web Apps 的 Maven 插件 "<appServicePlanName>"不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50893680/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com