简体   繁体   English

Python Azure 计时器 Function 带耐用实体

[英]Python Azure Timer Function with Durable Entity

I'm currently trying to work on my first Azure Function to act as an intermediary between Defender for Endpoints, and Azure Sentinel.我目前正在尝试使用我的第一个 Azure Function 作为端点防御者和 Azure Sentinel 之间的中介。 It runs every 5 minutes, and collects data matching specific filters from the Defender API to then forward as custom logs to Azure Sentinel.它每 5 分钟运行一次,并从 Defender API 收集匹配特定过滤器的数据,然后作为自定义日志转发到 Azure Sentinel。 Due to the authentication measures in place on Defender, I've set my script up using ADAL to do a device code logon the first time, then use the refresh tokens to do its scheduled running.由于在 Defender 上实施了身份验证措施,我使用 ADAL 设置我的脚本以进行第一次设备代码登录,然后使用刷新令牌进行计划运行。

This is where I've come across the problem;这是我遇到问题的地方; since Azure Functions are serverless by design, holding this refresh token somewhere for the next invocation has proven troublesome.由于 Azure 函数在设计上是无服务器的,因此在某处保存此刷新令牌以供下一次调用已证明很麻烦。 I'm trying to use Durable Functions, but the documentation for such a use case seems non-existent.我正在尝试使用 Durable Functions,但此类用例的文档似乎不存在。

Are there other appropriate methods to store a singular variable across invocations of an Azure Function?是否有其他适当的方法来跨 Azure Function 的调用存储单个变量?

There are more than one way to solve the problem you are facing with holding the refresh token for every new invocation Azure Functions.有不止一种方法可以解决您在每次新调用 Azure 函数时持有刷新令牌所面临的问题。

One way to solve the problem is by using a Azure Function Timer Trigger to request new access tokens and Azure Key Vault to store these tokens securely.解决该问题的一种方法是使用Azure Function 计时器触发器请求新的访问令牌,并使用 Azure Key Vault安全地存储这些令牌。 We want to save them in Key Vault so the next time we invoke our function to refresh our tokens again, we will use the updated values and the next function will be able to obtain that value when invocated.我们希望将它们保存在 Key Vault 中,以便下次调用 function 再次刷新我们的令牌时,我们将使用更新后的值,下一个 function 将能够在调用时获取该值。

在此处输入图像描述

Check this document to access secrets from key vault.查看此文档以访问密钥保管库中的机密。

Another way is enabling the token store in azure function and store it in blob storage.另一种方法是在 azure function 中启用令牌存储并将其存储在 blob 存储中。 Check this document for more information.查看此文档以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM