【发布时间】:2020-07-28 00:40:51
【问题描述】:
我正在使用 Azure Function Apps 开发 API。 API 在本地运行良好(使用 localhost)。但是,在发布到 Function App 后,我收到此错误:
[Errno 30] 只读文件系统
此错误发生在我将连接作为函数建立后,每次请求 API 时都允许建立新连接。数据取自 Azure Blob 存储容器。 代码:
DBConnection.py:
import os, uuid
from azure.storage.blob import BlockBlobService, AppendBlobService
from datetime import datetime
import pandas as pd
import dask.dataframe as dd
import logging
def BlobConnection() :
try:
print("Connecting...")
#Establish connection
container_name = 'somecontainer'
blob_name = 'some_name.csv'
file_path = 'somepath'
account_name = 'XXXXXX'
account_key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
blobService = BlockBlobService(account_name=account_name, account_key=account_key)
blobService.get_blob_to_path(container_name, blob_name, file_path)
df = dd.read_csv(file_path, dtype={'Bearing': 'int64', 'Speed': 'int64'})
df = df.compute()
return df
except Exception as ex:
print('Unable to connect!')
print('Exception:')
print(ex)
【问题讨论】:
标签: python azure azure-functions azure-blob-storage azure-function-app