更改 Azure 存储的 API 版本 API

Change the API Version of the Azure Storage API

我正在尝试部署一个从 Azure 存储帐户下载文件的函数应用程序。在本地,当我 运行 代码与 API 版本 2020-10-02 一起正常工作时。但是,当 运行 从 Azure 函数中调用代码时,它不起作用并引发以下错误:Result: Failure Exception: ValueError: Unsupported API version '2020-10-02'. Please select from: 2019-02-02 2019-07-07 2019-10-10 2019-12-12 2020-02-10 2020-04-08 2020-06-12

我使用以下代码:

# Connect to CDE-Currated with the source list data
cdecurrated = DataLakeServiceClient.from_connection_string(
    conn_str)
logging.info('Connected to CDE-Currated')

# Get the csv file based on the request and convert to xml
sl_file = cdecurrated.get_file_client(
    file_system='source-list', 
    file_path=f'{request["file_path"]}/{request["file_name"]}'
)
df = pd.read_csv(BytesIO(sl_file.download_file().readall()))

与其他 Storage Service API version 相比,只有 API version '2020-10-02' 的功能非常少。 Azure Functions 不支持您针对 API 版本 2020-10-02 收到的此错误。这可能是您收到错误的原因。

Failure Exception: ValueError: Unsupported API version '2020-10-02'. Please select from: 2019-02-02 2019-07-07 2019-10-10 2019-12-12 2020-02-10 2020-04-08 2020-06-12.

建议您按照错误中的建议使用 API version,或者您可以联系 Azure Support or Can raise a GitHub Issue 了解此问题的根本原因。

Python 的 Azure SDK 中存在错误 - 我的同事在创建有问题的 DataLakeServiceClient 时通过 manually specifying the api-version 解决了它。