本系列共计7篇文章:
1. Power Apps 拍照并调用on-premises 图像识别算法的效果演示
3.Power Apps 调用 AzureBlobStorage 连接器上传文件
4.制作一个Azure Functions API 调用 computer vision 检测图像内容
5. Power Apps 通过custom connector 自定义连接器调用云端公开的Azure Functions API并显示图像分析结果
6.将步骤4中的Functions添加本地容器支持并在本地运行,安装 on-premises gateway
7.Power Apps 通过 custom connector 自定义连接器调用 on-premises API并显示图像分析结果
本文介绍第六讲:
在本地容器环境中,托管Azure Functions HTTP 触发的 API。
视频演示如下:
图文步骤:
创建支持容器的Azure Functions:
运行
func init --docker
选择一个语言,如下图选择1 dotnet
下一步可以使用命令行创建一个函数或者通过vs code 等工具创建一个函数:
func new --name HttpExample --template "HTTP trigger" --authlevel "anonymous"
通过工具截图如下:
将上一讲中的 httptriggercsharp1.cs 和local.settings.json 两个文件中的内容复制到本节代码中。
目录结构如下:
在本地容器环境中编译并运行:
使用docker build -t 增加一个tag
docker build -t myfuncforpowerapp .
首次编译需要下载的东西比较多,请耐心等待:
在本地运行容器,注意在本案例中,需要使用 -e 向容器传递 computer vision 服务相关的 参数,此参数是配置在local.setting.json中的:
docker run -p 8080:80
-e ComputerVisionSubscriptionKey="ddbc8fxxxxxxxx"
-e ComputerVisionEndpoint="https://xxxxxxx.cognitiveservices.azure.com/" myfuncforpowerapp
示例如下图:
此时,我们使用局域网的IP:端口的形式,可以看到容器正在运行:
在局域网中的其他机器,可以调用该api: