Zlot
Zlot

Reputation: 47

Python config.py file in an Azure function

In my config.py file, I have this and I need it in order to run my function app.

'headers' : {'Content-Type': 'application/x-www-form-urlencoded', 'Cache-Control': 'no-cache'},
    'locallogdir': r'',
    'azure_config' : {
        'driver' : '{ODBC Driver 17 for SQL Server}',
        'server' : '',
        'UID' : '',
        'PWD' : '',
        'database' : ''
        },

Where/how would I put it into my Azure FunctionApp? Does it go into the settings.json and if so, how? I tried to put it in there and it didn't work.

Upvotes: 1

Views: 1770

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222522

You need to keep them as AppSettings. You can add these settings under the Function App settings, Here is the complete documentation

import logging
import os
import azure.functions as func

def main(req: func.HttpRequest) -> func.HttpResponse:

    # Get the setting named 'myAppSetting'
    my_app_setting_value = os.environ["myAppSetting"]
    logging.info(f'My app setting value:{my_app_setting_value}')

Upvotes: 2

Related Questions