-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DefaultAzureCredential fails to get a token when attempted from an Azure Function with a VNet integration #16175
Comments
Any update on this? |
@aangelisc hello, Mr Christou. I’m Daniel. I’ll be doing my best to help you. While I investigate this on my side, I would really appreciate if you could try the following: const defaultAzureCredential = new DefaultAzureCredential();
defaultAzureCredential.getToken("https://graph.microsoft.com/.default")
.then(result => console.log({ result }))
.catch(error => console.error(error)); What result do you get when you run that? (please make sure to remove any token or sensitive information). |
@aangelisc I’ve tried to reproduce this issue today without success. Please let us know how it goes when you test with |
Hi @sadasant, I still receive the same error as before even with the |
@aangelisc thank you for your response! Please give us some time to come up with a better answer. |
@aangelisc Hello, Mr. Christou. I’m still trying to reproduce the issue. So far, I have been unable to. I’ll share the steps I’m following. Would you please let me know if you spot anything I should be doing differently? In the meantime, I’m trying to reach other people in my team to make sure they take a peek at the issue you’re reporting and the steps I’m following, in case they may know something I don’t. Here are the steps I’m following:
Following those steps, I am able to see the authentication happening. Let me provide you the code from my repository: The folder structure:
The {
"name": "my-azure-function",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "func start",
},
"dependencies": {
"@azure/identity": "^1.3.0",
}
} The package-lock.json would be the one generated by NPM when running The {
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
} The {
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
}
]
} The const identity = require("@azure/identity");
module.exports = async function (context, req) {
context.log("JavaScript HTTP trigger function processed a request.");
process.env.AZURE_LOG_LEVEL = "verbose";
let totalTokensFound = 0;
console.log(`Trying the DefaultAzureCredential without parameters`);
try {
const credential = new identity.DefaultAzureCredential();
const result = await credential.getToken("https://graph.microsoft.com/.default"));
if (result && result.token) {
totalTokensFound++;
}
} catch (e) {
console.log(`DefaultAzureCredential without parameters error`, e);
}
console.log(`Total tokens found: ${totalTokensFound}`);
console.log(`Trying the ManagedIdentityCredential without parameters`);
try {
const credential = new identity.ManagedIdentityCredential();
const result = credential.getToken("https://graph.microsoft.com/.default"));
if (result && result.token) {
totalTokensFound++;
}
} catch (e) {
console.log(`ManagedIdentityCredential without parameters error`, e);
}
console.log(`Total tokens found: ${totalTokensFound}`);
context.res = {
// status: 200, /* Defaults to 200 */
body: "This HTTP triggered function executed successfully.",
};
}; Following those steps, I’m able to see logs that confirm to me that the tokens have been retrieved. I can also see those tokens if I change the logs to print the Is there anything in my approach that is fundamentally different from your approach? Thank you for your time, |
@aangelisc Just an update: I’ve reached out to my team and they report the same results as I do. |
Hi @sadasant, Thanks for the above. To clarify - were you also routing all traffic via the VNet? We are using the |
@aangelisc thank you Andreas! I will follow up on your feedback this week. Thank you so much for your response. Please give me a bit of time to catch up. |
@aangelisc I have configured both settings ( |
@aangelisc if you can help us debug this, do you mind setting this environment variable |
@aangelisc if possible, try the steps I shared above, on #16175 (comment), plus also setting |
Hi @sadasant, thank you for the quick response - I'll give this a go as soon as I get the chance! |
Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you! |
Dev sql microsoft.sql 2021 05 01 preview release (Azure#16289) * add base for Microsoft.sql * Update Readme.md * update version in swagger example files * remove ss * update swagger files * update readme.md * add missing json files * update custom-words.txt to address the spelling check * remove 201 define in ServerUpdate.json * Sync sql 2021 05 01 with main branch (Azure#16236) * Update comment.yml for publish pr (Azure#16166) * Update comment.yml * Update comment.yml * Bump dependencies (Azure#16170) * bump avocado * bump mocha * remove submodule (Azure#16171) * add azure-resource-manager-schema to servicelinker (Azure#16176) Co-authored-by: Nan Jiang <[email protected]> * Update pr assignment config (Azure#16175) * [Synapse] - fix scheme for Artifacts and update readme to include KQL scripts for October release (Azure#16035) * [Synapse] - fix scheme for Notebook, Spark Job definition and SQL script * Update dataset, linked service and pipeline * Update release tag for october release * Correct type of result limit * Add arguments for SynapseSparkJobActivityTypeProperties Co-authored-by: Dongwei Wang <[email protected]> * fix (Azure#16164) Merging the change to have accurate Swagger * Remove requirement of identity field in the request for TURN. (Azure#15966) * Remove requirement of identity field in the request. * Update PR * Address comment * change api version in readme for sdk release (Azure#16187) * Add blockchain to latest profile * Add additional types * api version change Co-authored-by: Mark Cowlishaw <[email protected]> Co-authored-by: Ping Zhu <[email protected]> * [Search] Rename types for better SDK code (Azure#16039) * Rename types for better SDK code * Rename Speller and Captions search options * Reorder parameters to have consistency across APIs * Remove 'SearchIndexer' prefix from projection selectors Remove 'global' prefix from default flags on custom entities * Change enum name AdlsGen2->AzureDataLakeStorageGen2 Change property name storageContainer->storageContainerName * move additional .NET SDK renames to the REST spec * Revert changes in KnowledgeStore which has GAed * Revert changes in CustomEntityLookupSkill which has GAed * Revert changes in SIKSBlobProjectionSelector which has GAed * Revert changes in SearchIndexerDataSourceType which has GAed * Rename ignoreResetRequirements->skipIndexerResetRequirementForCache * fix validStreamingUnits (Azure#16143) Co-authored-by: Roslyn Lu <[email protected]> * Fix schemas readme files (Azure#16207) * Fix schemas readme files * fix ref * add resourcemanager in module-name (Azure#16206) * add resourcemanager in module-name * add go track2 repo in readme.md * fix * Minor description update for createorupdate & update slot (Azure#15457) * add scmMinTlsVersion * modify description for createorupdate & update slot for all API versions Co-authored-by: Edwin Diaz <[email protected]> * [Hub Generated] Review request for Microsoft.Security to add version preview/2021-08-01-preview (Azure#16096) * Adds base for updating Microsoft.Security from version stable/2021-07-01 to version 2021-08-01-preview * Updates readme * Updates API version in new specs and examples * First pass at Microsoft.Security/standards for review/preview * Addressing Round-1 feedback, adding missing descriptions and changing scoping to match ProxyResource type * First pass for Microsoft.Security\standardComponents * Changes to fix a typo in an example spec * Added Microsoft.Security/standardAssignments * Fix naming convention issue * Removed types based on Hila's feedback * Changes to data model for both API calls * Fix example errors and typos * Add systemData to Microsoft.Security/standards * Changes to fix systemData linting * un-nest systemData fields in examples * More systemData placement * Naming convention name to assignments from standardAssignment * Additional example added * Changes to address descriptive comments on field types * Add systemData readOnly * prettier-fix against examples * Cleaned types to ref standard v2 common-types entry similar to securityForIoT * Re-added v2 folder? * Missed a change here? * Cleanup of v2 type completely, updated readme.md * Adds suppression to readme * Adds suppression to readme * Change modification to suppress operations linting Co-authored-by: Adam Holliday <[email protected]> * Yifanzhou/api version change (Azure#16191) * remove Catalog * update 2021-05-01-preview * delete 2021-09-01 * Update readme.md * Update purviewcatalog.json * change read-only property (Azure#16209) Co-authored-by: Parv Saxena <[email protected]> * Update account.json - make CollectionReferece type writable (Azure#16208) * Update account.json Updating the CollectionReference to be writeable to unblock the customers. * Update account.json Need the default set in the client SDK * Fixed an event name typo in its description. (Azure#16227) * Introduce new API version for Microsoft.ProviderHub 2021-09-01-preview (Azure#15723) * Introduce new API version for Microsoft.ProviderHub 2021-09-01-preview * Add PrivateResourceProviderConfigurations * Add PrivateRP examples * Fix enum type. * Fix enum again * Prettier * Fix prettier error * Add readme.md + prettier * Fix * Fix avocado error * Modify interface * Fix issue * Make it private preview * Remove private RP changes * Update SKU settings Co-authored-by: REDMOND\lakshv <[email protected]> Co-authored-by: He Huang <[email protected]> * fluidrelay_readme_config (Azure#16192) fluidrelay_readme_config * Add community gallery proxy resource (Azure#16043) * [Hub Generated] Public private branch 'dev-storagecache-Microsoft.StorageCache-2021-09-01' (Azure#16152) * Adds base for updating Microsoft.StorageCache from version stable/2021-05-01 to version 2021-09-01 * Updates readme * Updates API version in new specs and examples * 2021-09-01 API * Fix LintDiff Co-authored-by: rebecca337 <[email protected]> Co-authored-by: Rebecca Dupuis <[email protected]> * Fix S360 bugs for swagger FSPG 2020-02-14-preview, 2021-06-01-preview and 2021-06-01 APIs (Azure#15946) * Changed FSPG RestartParameter.failoverMode from string to enum for API 2021-06-01, 2021-06-01-preview, and 2021-06-15-privatepreview * Change enum first letter to lower case * Change to upper case * Fix S360 bugs for swagger FSPG 2020-02-14-preview, 2021-06-01-preview and 2021-06-01 APIs * Add email reminder when PR makes changes in Synapse (Azure#16116) * add email reminder to synapse * fix for comment * ServiceBus add batch tag (Azure#16229) * add code owner to synapse (Azure#16230) * [Datafactory] Power Query model changes for multiple queries (Azure#16158) * [Synapse] Add release tag for management SDK Oct. release (Azure#16213) * update release tag * fix for avocado Co-authored-by: Tianen <[email protected]> Co-authored-by: Zhenglai Zhang <[email protected]> Co-authored-by: Lei Ni <[email protected]> Co-authored-by: najian <[email protected]> Co-authored-by: Nan Jiang <[email protected]> Co-authored-by: Ray Chen <[email protected]> Co-authored-by: Dongwei Wang <[email protected]> Co-authored-by: Dongwei Wang <[email protected]> Co-authored-by: msyyc <[email protected]> Co-authored-by: AriZavala2 <[email protected]> Co-authored-by: PingZhu2232 <[email protected]> Co-authored-by: Mark Cowlishaw <[email protected]> Co-authored-by: Ping Zhu <[email protected]> Co-authored-by: Mohit Chakraborty <[email protected]> Co-authored-by: Roslyn Lu <[email protected]> Co-authored-by: Roslyn Lu <[email protected]> Co-authored-by: JiahuiPeng <[email protected]> Co-authored-by: edwin-msft <[email protected]> Co-authored-by: Edwin Diaz <[email protected]> Co-authored-by: dochollidayxx <[email protected]> Co-authored-by: Adam Holliday <[email protected]> Co-authored-by: yifan-zhou922 <[email protected]> Co-authored-by: Parv Saxena <[email protected]> Co-authored-by: Parv Saxena <[email protected]> Co-authored-by: hvermis <[email protected]> Co-authored-by: xuepingd <[email protected]> Co-authored-by: laxmankumar12 <[email protected]> Co-authored-by: REDMOND\lakshv <[email protected]> Co-authored-by: He Huang <[email protected]> Co-authored-by: Zed Lei <[email protected]> Co-authored-by: kangsun-ctrl <[email protected]> Co-authored-by: brpanask <[email protected]> Co-authored-by: rebecca337 <[email protected]> Co-authored-by: Rebecca Dupuis <[email protected]> Co-authored-by: xunsun-commits <[email protected]> Co-authored-by: Wan Yang <[email protected]> Co-authored-by: soma-ms <[email protected]> * remove blank line * address comments * address the description comment * update the swagger * remove ManagedInstances_ListOutboundNetworkDependenciesByManagedInstance * Update from microsoft.sql 2021-05-01-preview to base branch (Azure#16184) * Update comment.yml for publish pr (Azure#16166) * Update comment.yml * Update comment.yml * Bump dependencies (Azure#16170) * bump avocado * bump mocha * remove submodule (Azure#16171) * add azure-resource-manager-schema to servicelinker (Azure#16176) Co-authored-by: Nan Jiang <[email protected]> * Update pr assignment config (Azure#16175) * [Synapse] - fix scheme for Artifacts and update readme to include KQL scripts for October release (Azure#16035) * [Synapse] - fix scheme for Notebook, Spark Job definition and SQL script * Update dataset, linked service and pipeline * Update release tag for october release * Correct type of result limit * Add arguments for SynapseSparkJobActivityTypeProperties Co-authored-by: Dongwei Wang <[email protected]> * fix (Azure#16164) Merging the change to have accurate Swagger * update swagger files * update readme.md * add missing json files * update custom-words.txt to address the spelling check * remove 201 define in ServerUpdate.json * remove blank line * address comments * address the description comment * update the swagger * remove ManagedInstances_ListOutboundNetworkDependenciesByManagedInstance Co-authored-by: Tianen <[email protected]> Co-authored-by: Zhenglai Zhang <[email protected]> Co-authored-by: Lei Ni <[email protected]> Co-authored-by: najian <[email protected]> Co-authored-by: Nan Jiang <[email protected]> Co-authored-by: Ray Chen <[email protected]> Co-authored-by: Dongwei Wang <[email protected]> Co-authored-by: Dongwei Wang <[email protected]> Co-authored-by: msyyc <[email protected]> Co-authored-by: Tianen <[email protected]> Co-authored-by: Zhenglai Zhang <[email protected]> Co-authored-by: Lei Ni <[email protected]> Co-authored-by: najian <[email protected]> Co-authored-by: Nan Jiang <[email protected]> Co-authored-by: Ray Chen <[email protected]> Co-authored-by: Dongwei Wang <[email protected]> Co-authored-by: Dongwei Wang <[email protected]> Co-authored-by: msyyc <[email protected]> Co-authored-by: AriZavala2 <[email protected]> Co-authored-by: PingZhu2232 <[email protected]> Co-authored-by: Mark Cowlishaw <[email protected]> Co-authored-by: Ping Zhu <[email protected]> Co-authored-by: Mohit Chakraborty <[email protected]> Co-authored-by: Roslyn Lu <[email protected]> Co-authored-by: Roslyn Lu <[email protected]> Co-authored-by: JiahuiPeng <[email protected]> Co-authored-by: edwin-msft <[email protected]> Co-authored-by: Edwin Diaz <[email protected]> Co-authored-by: dochollidayxx <[email protected]> Co-authored-by: Adam Holliday <[email protected]> Co-authored-by: yifan-zhou922 <[email protected]> Co-authored-by: Parv Saxena <[email protected]> Co-authored-by: Parv Saxena <[email protected]> Co-authored-by: hvermis <[email protected]> Co-authored-by: xuepingd <[email protected]> Co-authored-by: laxmankumar12 <[email protected]> Co-authored-by: REDMOND\lakshv <[email protected]> Co-authored-by: He Huang <[email protected]> Co-authored-by: Zed Lei <[email protected]> Co-authored-by: kangsun-ctrl <[email protected]> Co-authored-by: brpanask <[email protected]> Co-authored-by: rebecca337 <[email protected]> Co-authored-by: Rebecca Dupuis <[email protected]> Co-authored-by: xunsun-commits <[email protected]> Co-authored-by: Wan Yang <[email protected]> Co-authored-by: soma-ms <[email protected]>
Describe the bug
A clear and concise description of what the bug is.
When attempting to use the @azure/identity package in an Azure Function (Linux) with a VNet integration the
GET
request to the/msi/token
endpoint fails with a500
status code and the following error message:I can see that the request is made to the following endpoint:
http://169.254.129.5:8081/msi/token?resource=https%3A%2F%2Fstorage.azure.com&api-version=2017-09-01
To Reproduce
Steps to reproduce the behavior:
@azure/identity
library (const defaultAzureCredential = new DefaultAzureCredential();
)Expected behavior
A clear and concise description of what you expected to happen.
The function app should successfully retrieve a token.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: