I’m deploying a Next.js application to Azure App Service and using Sequelize as my ORM. For authentication, I’m utilizing Azure Managed Identity with the Tedious library to connect to an SQL Server. While everything works perfectly in development, I encounter a “login failed” error in production.
I’m using the following configuration for Tedious:
const options: SequelizeOptions = {
database: process.env.DATABASE_NAME,
host: process.env.DB_HOST,
port: 1433,
dialect: "mssql",
logging: process.env.NODE_ENV === "development" ? console.log : false,
dialectModule: tedious,
dialectOptions: {
authentication: {
type: "azure-active-directory-default",
options: {
clientId: process.env.CLIENT_ID, // user - assigned
encypt: true,
},
},
},
};
I’ve tried both system-assigned and user-assigned identities. For the user-assigned identity.
What could be causing the managed identity authentication to fail in production while it works in development?
Are there any additional configurations needed for managed identity in an Azure App Service production environment?