简体   繁体   English

Azure function:System.InvalidOperationException:存储帐户连接字符串'不存在

[英]Azure function: System.InvalidOperationException: Storage account connection string 'does not exist

I have written an azure function, currently the azure function is acting as Webhook Consumer.我写了一个 azure function,目前 azure ZC1C425268E687385D1AB507 充当 Consumer。 The job of the function is to read Webhook events and save into azure storage. function 的工作是读取 Webhook 事件并保存到 azure 存储中。 I am using an HTTP trigger template to get the job done.我正在使用 HTTP 触发模板来完成工作。 I am able to receive the events from the Webhook, but when I try to write to azure storage it is giving me below error.我能够从 Webhook 接收事件,但是当我尝试写入 azure 存储时,它给了我以下错误。

I tried the option mentioned in this post , but no luck still getting the same error.我尝试了这篇文章中提到的选项,但没有运气仍然得到同样的错误。

System.InvalidOperationException: Storage account connection string 'AzureWebJobs<AzureStorageAccountName>' does not exist. Make sure that it is a defined App Setting.

Below is my function.json file下面是我的function.json文件

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "type": "blob",
      "name": "outputblob",
      "path": "test/demo",
      "direction": "out",
      "connection": "<AzureStorageAccountName>"
    }    
  ]
}

init .py初始化.py

import logging

import azure.functions as func

def main(req: func.HttpRequest,outputblob: func.Out[str]) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

    name = 'some_name'
    if not name:
        try:
            req_body = 'req_body_test'#req.get_json()
        except ValueError:
            pass
    else:
        name = 'name'#req_body.get('name')
    
    print(str(req.get_json()))

    outputblob.set(str(req.get_json()))

在此处输入图像描述

Please make sure you have already add the connection string to the local.settings.json on local or configuration settings on azure.请确保您已将连接字符串添加到本地或 azure 上的配置设置上的 local.settings.json。

Please test below code and settings files:请测试以下代码和设置文件:

__init__.py

import logging

import azure.functions as func


def main(req: func.HttpRequest,outputblob: func.Out[func.InputStream]) -> func.HttpResponse:
    outputblob.set("this is a test.")
    return func.HttpResponse(
            "Test.",
            status_code=200
    )

function.json

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "$return"
    },
    {
      "name": "outputblob",
      "type": "blob",
      "path": "test/demo",
      "connection": "MyStorageConnectionAppSetting",
      "direction": "out"
    }
  ]
}

local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "MyStorageConnectionAppSetting":"DefaultEndpointsProtocol=https;AccountName=0730bowmanwindow;AccountKey=xxxxxx;EndpointSuffix=core.windows.net"
  }
}

On azure:在 azure 上:

在此处输入图像描述

暂无
暂无

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

相关问题 如何以编程方式从 Python 中的 Azure 存储帐户中检索连接字符串 - How to programmatically retrieve the connection string from an Azure storage account in Python 如何使用Delalake python API 使用Azure 存储帐户连接字符串与Deltalake 连接? - How to connect with Deltalake using Delalake python API using Azure Storage account connection string? Azure Function(消耗 Linux 计划)未使用系统身份访问 zip 部署的存储帐户 - Azure Function (Consumption Linux Plan) is not working with System Identity to access the storage account for zip deployment Zip 从存储帐户部署 azure function - Zip deploy azure function from storage account 使用 Azure 函数将 gzip 文件存储在存储帐户中 - Store a gzip file in a storage account with Azure function Azure 函数 Python docker 容器:无法找到用于此绑定的 Azure 存储连接字符串 - Azure Function Python docker container: Unable to find an Azure Storage connection string to use for this binding 如果文件不存在,带有 blob 存储绑定的 Azure 函数将返回 500 http 响应代码 - Azure function with blob storage binding returns 500 http response code if file does not exist Json to excel from devops to storage account with help of azure function in python - Json to excel from devops to storage account with help of azure function in python Azure blob 存储错误:指定的资源不存在 - Azure blob storage Error: The specified resource does not exist Azure Cosmos Python“系统中不存在指定id的实体 - Azure Cosmos Python "Entity with the specified id does not exist in the system
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM