Dapr 和 Azure Functions : Hello world
本篇文章内容来自 https://charliedigital.com/2021/07/01/dapr-and-azure-functions-part-1-hello-world/ ,是按这篇文章的操作记录。
使用 Azure Functions Core Tools 可以在本地计算机上通过命令提示符或终端开发和测试函数。 本地函数可以连接到实时 Azure 服务,你可以在本地计算机上使用完整的 Functions 运行时调试函数。安装使用 Azure Functions Core Tools: https://docs.microsoft.com/zh-cn/azure/azure-functions/functions-run-local?tabs=v4%2Cwindows%2Ccsharp%2Cportal%2Cbash%2Ckeda
第一步:创建 函数项目:
创建一个项目文件夹 dapr-func,使用Visual Studio code 打开并运行下面的命令
func init --name HelloWorldFunc --worker-runtime dotnet
第二步:添加HelloWorld 函数
运行命令 func function new --name HelloWorld --authlevel anonymous ,选择
HttpTrigger
运行命令 func start 测试函数
浏览器访问 http://localhost:7071/api/HelloWorld
第三步: 用Dapr 来运行函数
使用下列命令通过Dapr 边车运行函数
dapr run --app-id helloworldfuncdapr --app-port 7071 --dapr-http-port 7070 func start
--app-id helloworldfuncdapr
是一个应用标识符,他将是服务URL的一部分--app-port 7071
是应用程序将与 Dapr 通信的端口--dapr-http-port 7070
是 Dapr 通过 sidecar 暴露应用程序端口(在本例中为 7071)的地方func start
运行函数应用程序
我们仍然可以使用 直接访问 Function http://localhost:7071/api/HelloWorld
,但现在我们也可以使用 Dapr sidecar 访问它http://localhost:7070/v1.0/invoke/helloworldfuncdapr/method/api/HelloWorld
让我们分解网址:
http://localhost:7070/v1.0/invoke
注意我们指定的端口 7070--dapr-http-port
/helloworldfuncdapr
是我们之前指定的--app-id
/method/api/HelloWorld
是到 Functions 端点的路由
Dapr 和 Functions 在本地机器上的不同进程中运行,Dapr 充当转发代理。func.exe
正在运行我们的 Functions 应用程序,而 Dapr 在这一点上或多或少像一个简单的 HTTP 转发代理。
Dapr 和 Azure Functions : Hello world的更多相关文章
- Azure Functions + Azure Batch实现MP3音频转码方案
客户需求 客户的环境是一个网络音乐播放系统,根据网络情况提供给手机用户收听各种码率的MP3歌曲,在客户没购买歌曲的情况下提供一个三十秒内的试听版本.这样一个系统非常明确地一个需求就是会定期需要将一批从 ...
- 使用VS code 创建 Azure Functions,从blob触发,解析,发送至Service Bus
更多内容,关注公众号:来学云计算 场景: 某设备定时于每天23:00左右将一天的运行日志.devicelogtxt上传到Azure Blob,期待Blob文件上传后, 自动通过Azure Functi ...
- 设备数据通过Azure Functions 推送到 Power BI 数据大屏进行展示(2.Azure Functions实战)
本案例适用于开发者入门理解Azure Functions/ IoT Hub / Service Bus / Power BI等几款产品. 主要实战的内容为: 将设备遥测数据上传到物联网中心, 将遥测数 ...
- 设备数据通过Azure Functions 推送到 Power BI 数据大屏进行展示(1.准备工作)
本案例适用于开发者入门理解Azure Functions/ IoT Hub / Service Bus / Power BI等几款产品. 主要实战的内容为: 将设备遥测数据上传到物联网中心, 将遥测数 ...
- 通过流量管理器和 Azure Functions(作为代理)为全球用户提供最靠近的认知服务(或自定义API)
本实战是一个中等复杂度的综合性实战,涉及到的内容有TrafficManager,AzureFunctions,域名/域名解析等几个内容. 本案例基础介绍: https://www.bilibili.c ...
- 使用 Visual Studio 开发、测试和部署 Azure Functions(二)测试,部署
1,引言 上一篇介绍了使用使用 Visual Studio 开发 "Azure Functions" 函数,此篇介绍 “Azure Functions” 的测试以及直接从 Vist ...
- 使用 Visual Studio 开发、测试和部署 Azure Functions(一)开发
1,什么是Azure functions Azure Functions 是 Microsoft Azure 提供的完全托管的 PaaS 服务,用于实现无服务器体系结构. Azure Function ...
- 使用Azure Functions 在web 应用中启用自动更新(一)分析基于轮询的 Web 应用的限制
1,引言 上一篇介绍了使用使用 Visual Studio 开发 "Azure Functions" 函数,此篇介绍 “Azure Functions” 的测试以及直接从 Vist ...
- 利用Azure Functions和k8s构建Serverless计算平台
题记:昨晚在一个技术社区直播分享了"利用Azure Functions和k8s构建Serverless计算平台"这一话题.整个分享分为4个部分:Serverless概念的介绍.Az ...
随机推荐
- leetcode5225最大相等频率
题目 正整数数组nums,找到满足条件的最长前缀,返回其长度.该前缀满足:删除一个元素后,剩下的每个数字出现的次数相同. ps:如果删除后没有元素存在,也可以认为每个数字有相同的次数. 数组长度:[2 ...
- 1067 - Combinations
1067 - Combinations PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Giv ...
- C# 编写 Windows 动态桌面软件实现(一)之桌面交互功能
DreamScene2 1.3 版本已经发布了,现在支持鼠标和桌面交互功能.这个功能不会影响性能,基本不占用 CPU.这个功能让我对 Windows 消息机制有了更深入的理解,在这篇博客中我会详细介绍 ...
- Chapter 5 Interaction
目录 5.1 Interaction requires a joint intervention 5.2 Identifying interaction 5.3 Counterfactual resp ...
- uniapp跳转webview后H5不执行UniAppJSBridgeReady 回调无用
开始时我在真机上测试使用 <web-view :src="'/hybrid/html/pages/index/index.html?userInfo='+JSON.stringify( ...
- 【Warrior刷题笔记】剑指offer 6 24 35. 三道题,让你学会链表递归迭代辅助栈
题目一 从尾到头打印链表 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-l ...
- JZOJ 3296 Luogu P3296 [SDOI2013]刺客信条
前言 做法来自:@pzrpzr ,写一下!Orz pzr! 题目大意 \(n\) 个点的无根树,每个点有两个 \(0/1\) 权值,合适地安排节点在同构树中的顺序,使得前后对应的权值不同节点个数最小, ...
- 抛弃go-micro,使用极简微服务框架Bull
简介 Bull是一款基于GO语言的极简微服务框架. 使用GRPC作为RPC协议,使用ETCD作为注册中心. 框架目前已经实现了服务注册.服务发现(客户端轮训)功能. 整体架构 代码地址 https:/ ...
- 谈谈 StringBuffer 和 StringBuilder 的历史故事
1.前言 众所周知,StringBuffer 是线程安全的 ,而StringBuilder 不是线程安全的 ,但是 StringBuilder 速度会更快. 事实上 作为一个字符串拼接 方法 ,在线 ...
- PyCharm - 关联mysql失败 - Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually.
时区错误,MySQL默认的时区是UTC时区,比北京时间晚8个小时. 所以要修改mysql的时长 在mysql的命令模式下,输入: set global time_zone='+8:00'; 再次连接成 ...