实现 Azure 服务与函数的无缝集成
1. 动态向最终用户发送电子邮件通知
1.1 准备工作
在开始之前,需要确保完成以下配置:
1. 创建 SendGrid 账户,并在 SendGrid 门户中生成 API 密钥。
2. 在函数应用的配置中创建应用设置配置。
3. 在 SendGrid 输出(消息)绑定中配置应用设置密钥。
1.2 具体操作步骤
1.2.1 在 RegisterUser 函数中接受新的电子邮件参数
对 RegisterUser 函数进行修改,以接受电子邮件参数,具体步骤如下:
1. 打开 RegisterUser 函数的 run.csx 文件,添加一个新的字符串变量,用于从请求对象中接受名为 email 的新输入参数。同时,将 UserProfile 对象序列化,并将 JSON 内容存储到队列消息中。示例代码如下:
string firstname=null,lastname = null, email = null;
...
...
email = inputJson.email;
...
...
UserProfile objUserProfile = new UserProfile(firstname, lastname, string profilePicUrl,email);
...
...
await NotificationQueueItem.AddAsync(JsonConvert.SerializeObject(objUserProfile));
超级会员免费看
订阅专栏 解锁全文
1129

被折叠的 条评论
为什么被折叠?



