Search code examples
pythonazureazure-functionsazure-storage

Change the API Version of the Azure Storage API


I'm trying to deploy a function app which downloads a file from an azure storage account. Locally when I run the code it works fine with API Version 2020-10-02. However, when running the code from an Azure Function it does not work and raises the following error: 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

I use the following code:

# 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()))

Solution

  • There is a bug in the Azure SDK for Python - my colleague got it working by manually specifying the api-version when creating the DataLakeServiceClient that had the issue.