I have this local.settings.json in my local Azure function (Http triggered)
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python"
},
"ConnectionStrings": {
"SQLConnectionString": "valid connection string "
}
}
I want to access variable "SQLConnectionString" and use in my Python3.6 code. I have found many guides for accessing this variable with C#, but I wasn't lucky to find how to do it via python.
I test it just now and met the same error. You should modify your local.setting.json as below:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python",
"SQLConnectionString": "cnx = mysql.connector.connect(user=\"test@hurytestmysqlserver\", password=\"Password123\", host=\"testmysqlserver.mysql.database.azure.com\", port=3306, database=\"xxx\", .....)"
}
}
but not
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python"
},
"ConnectionStrings": {
"SQLConnectionString": "xxxxxxxx"
}
}
Please have a try.
Just as a supplement~(I wanted to provide the solution "os.environ[xxx]" but saw the solution provided by HariHaran, haha~)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With