英文:
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
).
Update it to make it a placeholder like:
<!-- function app name -->
<appName>${functionAppNameToDeploy}</appName>
<!-- function app resource group -->
<resourceGroup>${resourceGroupToDeploy}</resourceGroup>
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论