Azure错误:数据保护系统无法创建新密钥,因为已禁用自动生成密钥

2024-04-19 03:59:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用visualstudio代码在本地计算机上运行azure函数。 我的主.py看起来像这样:

import logging

import azure.functions as func

def main(event: func.EventHubEvent):
    logging.info('Python EventHub trigger processed an event: %s', event.get_body().decode('utf-8'))

我的主机.json文件如下所示:

{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[1.*, 2.0.0)"
  }
}

我的函数.json看起来像这样:

{
  "scriptFile": "main.py",
  "bindings": [
    {
      "type": "eventHubTrigger",
      "name": "event",
      "direction": "in",
      "eventHubName": "myhubName",
      "connection": "myHubConnection",
      "cardinality": "many",
      "consumerGroup": "$Default"
    }
  ]
}

问题是当我运行这个时,它会抛出以下错误:

A host error has occurred at Microsoft.AspNetCore.DataProtection: An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information. Microsoft.AspNetCore.DataProtection: The key ring does not contain a valid default protection key. The data protection system cannot create a new key because auto-generation of keys is disabled. Value cannot be null. Parameter name: provider

我不知道我错过了什么?感谢您的帮助


Tags: key函数namepyimporteventjsonmain
1条回答
网友
1楼 · 发布于 2024-04-19 03:59:04

Azure存储帐户出现问题:

确保local.settings.json文件具有存储帐户的正确凭据

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "MyStorageKey",
    "FUNCTIONS_WORKER_RUNTIME": "python",
  }
}

相关问题 更多 >