Hi, I've been going through
https://learn.microsoft.com/en-us/azure/app-service/overview-managed-identity?tabs=powershell
trying to generate an access token for a function app, it seems to be working OK when working with a powershell app, however when doing the same request from a NodeJS app I keep getting back the following error
"message": "400 - \"{\\\"error\\\":{\\\"code\\\":\\\"UnsupportedApiVersion\\\",\\\"message\\\":\\\"The HTTP resource that matches the request URI 'http://localhost:8081/msi/token/?resource=https://database.windows.net/&api-version=2019-08-01' does not support the API version '2019-08-01'.\\\",\\\"innerError\\\":null}}\"",
I've tried using different API versions with no success, the documentation specifies to use 2019-08-01 but the service says it's not supported
this is the code I'm currently using to try and request said token
async function getToken() {
const resource = "https://database.windows.net/";
const options = {
method: "GET",
uri: `${process.env["IDENTITY_ENDPOINT"]}/?resource=${resource}&api-version=2019-08-01`,
headers: {
"X-IDENTITY-HEADER": process.env["IDENTITY_HEADER"],
},
};
try {
const response = await rp(options);
return Promise.resolve(response);
} catch (error) {
return Promise.resolve(error);
// return Promise.reject(error);
}
}
any insights into what could be happening here are greatly appreciated
edit:
As an update, it seems to be working OK if I set my node js app on a windows server as well but getting the unsupported API version for a node js app on linux which is what I'm trying to actually work with.