在本地开发 Azure 功能 [英] Developing Azure functions locally

查看:42
本文介绍了在本地开发 Azure 功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在领导一个由 azure 函数开发人员组成的大型团队.因此,Microsoft 引用的大多数使用 azure Web 界面的示例都不适合我.我正在使用模拟器在本地开发 Azure 功能以节省一些成本.我通过 Visual Studio 将我的所有功能发布到我的集成环境中.

I am leading a large team of azure functions developers. So, most of the examples quoted by Microsoft using the azure web interface don't work for me. I am developing Azure functions locally using emulators to save some costs. I publish all my functions through visual studio into my integration environment.

我正在开发一堆需要 api 网关来处理使用 Azure AD B2C 的身份验证工作流的天蓝色函数.现在,没有可以在本地运行的 api 网关模拟器或 Azure AD B2C 模拟器.我的身份验证工作流包括拦截对 api 的请求,将它们重定向到 AD B2C 进行身份验证,然后将 auth-token 添加到 http 标头,然后调用 http 触发的 azure 函数.

I am developing a bunch of azure functions that need the api gateway to handle the authentication workflows using Azure AD B2C. Now, there's no api gateway emulator or an Azure AD B2C emulator that I can run locally. My authentication workflows involve intercepting requests to the api, redirecting them to AD B2C for authentication and the subsequent addition of the auth-token to the http header and then invoking the http-triggered azure functions.

现在,问题变成了,如何测试身份验证工作流程?如何设置 api 网关以将我在 Visual Studio 中本地运行的函数注册为我在云端的 api 网关的 api 端点?

Now, the question becomes, how do I test authentication workflows? How can I setup the api gateway to register my functions running locally in visual studio as api endpoint for my api gateway in the cloud?

推荐答案

我做了什么:

  1. 添加了一个授权"API,用于处理针对外国当局的通用授权.此 API 返回我自己的 JWT 以及我自己的自定义声明,该声明会持续一段时间.
  2. 更改了我的所有其他 API 以使用我的自定义 JWT.

优点:

  • 超级容易在本地测试.我只是将#if DEBUG 部分添加到授权 API 以跳过正常授权并为我提供我设计的 JWT.
  • 我可以在声明中添加我想要的任何内容,因此我将其用作缓存以减少外部授权调用.

这篇关于在本地开发 Azure 功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆