Skip to content Skip to sidebar Skip to footer

How To Handle Azure Python Function Exception Handling?

I'm new to Python exception handling. How do I correctly try the following, except if .get_entity fails, but pass if Status 200? Here is where I'm at: Its not correct though. Hopi

Solution 1:

You can change your code like below:

def get_table_row(TableName, PartitionKey, RowKey):
    try:
        table_lookup = table_service.get_entity(TableName, PartitionKey, RowKey)
    except AzureMissingResourceHttpError as e:
        if e.status_code == 200:
            return table_lookup
        else:
            logging.error(f'#### Status Code: {e.status_code} ####')
            return "whatever you want"
    else:
        return table_lookup

Post a Comment for "How To Handle Azure Python Function Exception Handling?"