python - Azure Functions 中的凭据、传递一个凭据还是根据需要调用?

标签 python azure azure-functions azure-durable-functions

我的耐用功能应用程序间歇性出现凭据问题。

ManagedIdentityCredential will use App Service managed identity

EnvironmentCredential.get_token failed: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.

DefaultAzureCredential - EnvironmentCredential is unavailable

在每个事件中我调用DefaultAzureCredential

# some activity function
from azure.identity import DefaultAzureCredential

credential = DefaultAzureCredential()

def my_func()...

在我的协调器中创建一个凭证一次并将其传递给我的事件会更好吗?我也在使用系统分配的身份,因此我应该使用 ManagedIdentityCredential 来避免 DefaultAzureCredential 所做的常量检查吗?

from azure.identity import ManagedIdentityCredential
import azure.durable_functions as df


def orchestrator_function(context: df.DurableOrchestrationContext):
    
    # Create the credentials
    credentials = ManagedIdentityCredential()

    # Pass it to my activity instead of my activity creating its own
    activity = yield context.call_activity("my_activity", credentials)
    

最佳答案

Would it be better to create a credential in my orchestrator, once, and pass it around to my activities?

据我了解,如果您的Orchestrator function调用Activity function多次,最好通过CredentialOrchestrator function ;如果只调用一次,我认为创建一个 Credential 是一样的在 Activity function .

I am also using system assigned identity, so should I use ManagedIdentityCredential instead to avoid the constant checks DefaultAzureCredential does?

如果您使用System assigned identity ,可以直接使用ManagedIdentityCredential ,因为DefaultAzureCredential将检查多个身份,直到其中一个提供 token 。

为了更好的理解,可以引用这个official document .

enter image description here

EnvironmentCredential is unavailable是由 DefaultAzureRedential 引起的无法从 EnvironmentCredential 请求 token ,这是预期的结果。

关于python - Azure Functions 中的凭据、传递一个凭据还是根据需要调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66001330/

相关文章:

Azure Powershell 函数使用推送输出绑定(bind)附加到 Blob

python - 为什么 sys.stdout = None 有效?

python - 按 Numpy 的中位数分组(不含 Pandas)

azure - 从 ADF 和接收器调用存储过程到 Azure SQL 数据库

azure - 如何为 Azure VM 拥有域

c# - azure-functions 中的程序集引用

python - 嵌套 for 循环检查 python 列表的元素

python - 使用 Pandas 从 Redshift 读取 bigint (int8) 列数据,无需科学记数法

java - 我应该在 Android 中使用 Azure 中的哪个 sdk 库来使用媒体服务?

azure - 您可以从 Azure 队列触发器中弹出消息吗