将功能定义定义为API管理,作为CI流程的一部分
我们希望在每部部署Azure函数的情况下将函数定义导入函数定义的过程自动化。在Azure门户中,有一种非常简单的方法可以通过UI导入函数定义,但是它们似乎并不是任何API/CLI/POWERSHELL库来自动化此过程。
我们设法创建了一个解决方法,该解决方法涉及使用C#保持函数应用程序的最新定义。 OpenAPI库,然后使用az apim导入
cli命令作为我们部署管道的一部分,但感觉就像额外的工作保持OpenAPI定义的最新定义,并且在我们功能的每个端点上都准确,并且最可取要自动将门户网站在引擎盖下导入函数应用程序时所做的事情(这不需要OpenAPI定义在源代码中保持最新状态)。任何帮助将不胜感激。
我们正在为CI/CD管道和释放使用Azure DevOps。
We're looking to automate the process of importing a function definition into our CD process with every deployment of our azure functions. Within the azure portal, there is a very straightforward way to import a function definition through the UI, but their doesn't appear to be any api/cli/powershell library to automate this process.
We have managed to create a workaround which involves keeping our function app definitions up to date using the C# OpenApi library and then using the az apim import
cli command as part of our deployment pipeline but it feels like extra work keeping the OpenApi definition up to date and accurate on every endpoint of our function and it would be preferable to automate what the portal is doing under the hood when you import a function app (this does not require an openapi definition being kept up to date in source code). Any help would be greatly appreciated.
We are using Azure Devops for our CI/CD pipelines and releases.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有一些选择。您没有指定您是否已经有一些现有的基础架构CI工具,但是我最熟悉在Terraform中这样做。
有关如何将Terraform设置到管道中的教程。
一旦您将Terraform整合到了Terraform之后,就可以轻松将API定义添加到您的APIM实例中。并将其链接到您的功能后端。
文章及其一些代码样本:
现在,正如您在本文中看到的那样,它谈到了导入OpenAPI文件以定义实际API。没有一个很好的方法可以自动执行此操作,但是有一种使用Swagger的内置的Tofile工具:
当您在管道中运行构建时,将生成此文件,然后您可以在基础架构阶段将其引用OpenAPI文件自动在APIM中生成该API。
You've got a few options for this. You didn't specify if you already have some existing infrastructure CI tools, but I'm most familiar with doing this in terraform.
Tutorial on how to setup terraform into your pipeline.
Once you have terraform integrated you can easily add API definitions into your APIM instance. And link that up to your function backend.
Article and some code samples from it:
Now as you can see in this article it talks about importing an OpenApi file to define the actual api. There isn't a great way to do this automatically, but there is a way using swagger's built in tofile tool:
When you run your build in your pipeline this file will be generated and then you can reference it in your infrastructure stage to use that OpenAPI file to automatically generate that API in APIM.