'Unable to connect to mysql flexible server from deployed node azure function using sequelize and Serverless Framework
As the title says, I have a series of azure functions (function app) which call on a database (mysql) also deployed on azure using sequelize and all of them are in the same resource group (deployed to us-east-2).
When I run the api locally everything works, I am able to make calls to the api and it is able to communicate to the DB. I can deploy everything just fine using Serverless Framework but when I try to make a call to one of the deployed endpoints I get the following 500 error returned:
{ "name": "SequelizeConnectionError", "parent": { "errno": "EACCES", "code": "EACCES", "syscall": "connect", "address": "127.0.0.1", "port": 3306, "fatal": true }, "original": { "errno": "EACCES", "code": "EACCES", "syscall": "connect", "address": "127.0.0.1", "port": 3306, "fatal": true } }
Could this connection error be due to my credentials not being deployed with sequelize? If so, how do I deploy them? I have them stored as environment variables in a local.settings.json file. I checked the firewall and since this is a Proof of Concept with dummy data I am just letting everything in so it can't be that.
Here is my sequelize connection:
const {
Sequelize,
} = require("sequelize");
const DATABASE_HOST = process.env["DATABASE_HOST"];
const DATABASE_CATALOG = process.env["DATABASE_CATALOG"];
const DATABASE_PORT = process.env["DATABASE_PORT"];
const DATABASE_USER = process.env["DATABASE_USER"];
const DATABASE_PASSWORD = process.env["DATABASE_PASSWORD"];
const sequelize = new Sequelize(DATABASE_CATALOG, DATABASE_USER, DATABASE_PASSWORD, {
host: DATABASE_HOST,
port: DATABASE_PORT,
dialect: 'mysql',
ssl: true,
"dialectOptions": {
"ssl": {
"require": true
}
},
pool: {
max: 20,
min: 0,
acquire: 120000,
idle: 10000
}
});
module.exports = sequelize;
Any help would be greatly appreciated, its a side project and I have been staring at this for way too long.
Solution 1:[1]
If all you want is the Spanish only subtitles (since there's no hrefs and that's a thing for the future) you can grab all descarga elements and grab the first one and then every 3rd one onwards.
You should end up with 10 titles.
Here's how:
import requests
from bs4 import BeautifulSoup
headers = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:95.0) Gecko/20100101 Firefox/95.0",
}
page = requests.get("https://www.tusubtitulo.com/season/4674/1", headers=headers).text
spanish_only = [
a["title"] for a in BeautifulSoup(page, "lxml").select(".bt_descarga")[1::3]
]
print("\n".join(spanish_only))
Output:
Invasion (2021) 1x01 - Last Day
Invasion (2021) 1x02 - Crash
Invasion (2021) 1x03 - Orion
Invasion (2021) 1x04 - The King is Dead
Invasion (2021) 1x05 - Going Home
Invasion (2021) 1x06 - Home Invasion
Invasion (2021) 1x07 - Hope
Invasion (2021) 1x08 - Contact
Invasion (2021) 1x09 - Full of Stars
Invasion (2021) 1x10 - First Day
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | baduker |
