如何使用Maven插件部署具有多个名称的Azure函数?

huangapple go评论96阅读模式
英文:

How can I deploy a Azure Function with multiple Names with the Maven plugin?

问题

有一种简单的方法可以将我编写的函数发布到多个命名实例吗?即,我希望编写好我的函数,然后将其部署到FunctionUserA、FunctionUserB等。我知道可以使用Azure CLI来完成这个操作,但希望能够完全通过maven来实现。

英文:

Is there a straightforward way to publish a function I build to multiple named instances? IE, I want to build my function, then deploy it to FunctionUserA, FunctionUserB, etc. I know I can use the Azure CLI to do this, but was hoping it could all be done through maven.

答案1

得分: 1

当您使用以下命令通过mvn archetype:generate -DarchetypeGroupId=com.microsoft.azure -DarchetypeArtifactId=azure-functions-archetype -DjavaVersion=8创建Azure函数时,生成的pom.xml文件应该有一个名为functionAppName的属性,如下所示,该属性在通过maven(mvn azure-functions:deploy)部署时被引用:

<!-- 函数应用名称 -->
<appName>${functionAppNameToDeploy}</appName>
<!-- 函数应用资源组 -->
<resourceGroup>${resourceGroupToDeploy}</resourceGroup>

然后,您可以在运行部署命令时传递functionAppName参数(注意需要使用'D'前缀)。同样,如果需要,您可以向mvn命令传递任何自定义参数。

mvn azure-functions:deploy -DfunctionAppNameToDeploy=FunctionUserA -DresourceGroupToDeploy=MyResourceGroup
mvn azure-functions:deploy -DfunctionAppNameToDeploy=FunctionUserB -DresourceGroupToDeploy=MyResourceGroup

但据我所知,您不能一次性地将其部署到多个应用程序。需要分别使用不同的函数应用名称运行上述命令。

英文:

When you create Azure Function by using mvn archetype:generate -DarchetypeGroupId=com.microsoft.azure -DarchetypeArtifactId=azure-functions-archetype -DjavaVersion=8, the generated pom.xml should have a property functionAppName like below which is referred when deploying via maven (mvn azure-functions:deploy).
如何使用Maven插件部署具有多个名称的Azure函数?
Update it to make it a placeholder like:

&lt;!-- function app name --&gt;
&lt;appName&gt;${functionAppNameToDeploy}&lt;/appName&gt;
&lt;!-- function app resource group --&gt;
&lt;resourceGroup&gt;${resourceGroupToDeploy}&lt;/resourceGroup&gt;

Then you can pass the functionAppName argument while running deploy command (note 'D' prefix is required). Likewise you can pass any custom arguments if required to mvn command in general.

mvn azure-functions:deploy -DfunctionAppNameToDeploy=FunctionUserA -DresourceGroupToDeploy=MyResourceGroup
mvn azure-functions:deploy -DfunctionAppNameToDeploy=FunctionUserB -DresourceGroupToDeploy=MyResourceGroup

But AFAIK you cannot do it to deploy to multiple at one shot AFAIK. Need to run the above with different function app names separately.

huangapple
  • 本文由 发表于 2020年10月15日 22:56:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/64374363.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定