Comments (12)
AFAIK,
This is the only API and it lists tenants. It only provides the tenantId and does not provide the name of the tenant.
@vivsriaus @ravbhatnagar - Is there an API that can provide more info about tenants a GET
on
https://management.azure.com/tenants/{tenantId}
=> Tenants_Get
from azure-sdk-for-js.
ARM's /tenants API will list more information about a tenant (including the display name and domain) if you use api-version 2017-08-01:
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/tenants?api-version=2017-08-01
(redacted)
{
"id": "/tenants/f102019f-b12d-446e-a653-71ef78828f59",
"tenantId": "f102019f-b12d-446e-a653-71ef78828f59",
"countryCode": "US",
"displayName": "vivektest",
"domains": [
"vivektest.onmicrosoft.com"
]
}
Issue to update api-version is here
from azure-sdk-for-js.
Thanks for the response - until the referenced issue is fixed, can I set the API version manually for now via the SDK call to tenants.list
?
from azure-sdk-for-js.
Nope that wont work. Because the SDK is wired to deserialize the response based on the predefined api-version.
However, we have something wonderful to unblock you. Every client has a generic sendRequest() method that accepts a callback or returns a promise. Since the client already has the credentials object so authentication is not a problem. You can make any request to Azure.
Ideally you would be doing
let client = new ResourceManager.SubscriptionClient(creds);
client.tenants.list((err, result) => {
. . . // but this one only resturns an array of id and tenantId
});
So based on the above information provided by @vivsriaus about the REST API, you can use the generic sendRequest() method that is present on every client, until an sdk is published with that api-version (2017-08-01).
- Promise based
const ResourceManager = require('azure-arm-resource');
const msRestAzure = require('ms-rest-azure');
msRestAzure.interactiveLogin().then((creds) => {
let client = new ResourceManager.SubscriptionClient(creds);
const request = {
url: 'https://management.azure.com/tenants?api-version=2017-08-01',
method: 'GET'
};
return client.sendRequest(request);
}).then((result) => {
// The response body as a json object;
console.log(result);
}).catch((err) => {
console.log(err);
});
- Callback based
const ResourceManager = require('azure-arm-resource');
const msRestAzure = require('ms-rest-azure');
msRestAzure.interactiveLogin((err, creds) => {
if (err) {
return console.log(err);
}
let client = new ResourceManager.SubscriptionClient(creds);
const request = {
url: 'https://management.azure.com/tenants?api-version=2017-08-01',
method: 'GET'
};
return client.sendRequest(request, (err, result, request, response) => {
if (err) {
return console.log(err);
}
// The parsed response body
console.log(result);
});
});
Documentation for sendRequest(), in case you need it in the future.
from azure-sdk-for-js.
Thanks for the tip on sendRequest
, useful to know thanks!
I've tried the sample above and I'm still only getting back a response with the original info:
{
value: [
{
id: '/tenants/<tenantId>',
tenantId: '<tenantId>'
}
]
}
Is there anything else I can check or let you know to help diagnose?
Thanks.
from azure-sdk-for-js.
FYI, we're using CoffeeScript - here's the code that produces the above:
exports.getTenants = (creds, callback) ->
client = new resourceManager.SubscriptionClient creds
request =
url: 'https://management.azure.com/tenants?api-version=2017-08-01'
method: 'GET'
client.sendRequest request, (err, result, request, response) ->
if err then return callback err
callback null, result
from azure-sdk-for-js.
Do check the actual request and response (3rd and 4th parameter in the callback) to make sure that everything is as expected.
Well I just ran the following script and everything worked as expected.
const ResourceManager = require('azure-arm-resource');
const msrestazure = require('ms-rest-azure');
msrestazure.loginWithServicePrincipalSecret('clientId', 'secret', 'tenantId', (err, creds) => {
if (err) return console.log(err);
const client = new ResourceManager.SubscriptionClient(creds);
client.sendRequest({
url: 'https://management.azure.com/tenants?api-version=2017-08-01',
method: 'GET'
}, (err, result, request, response) => {
if (err) {
console.log(err);
return;
}
console.dir(result, {depth: null});
});
});
The result is:
{ value:
[ { id: '/tenants/000000-9089-7676-abc8-ababa121234',
tenantId: '000000-9089-7676-abc8-ababa121234',
countryCode: 'US',
displayName: 'MyTenant',
domains: [ 'azTest.com', 'azTest.onmicrosoft.com' ] } ] }
from azure-sdk-for-js.
Weirdly, I can only get the same response back as using the tenants.list
function. I cleared my node_modules, fresh npm install (we're using 2.2.1-preview of the SDK) and still no joy.
The request and response look fine and the response body is the same as the parsed result.
from azure-sdk-for-js.
@vivsriaus is this API version deployed in all the regions? Can it be possible if the api version is not deployed then it falls back to the old version?
@MichaelBurgess can you provide us the raw request (strip out authentication header)
from azure-sdk-for-js.
FYI, I am making the request from the UK. Don't know if that has any impact on things?
{
rawResponse: false,
queryString: {},
url: 'https://management.azure.com/tenants?api-version=2017-08-01',
method: 'GET',
headers:
{
'accept-language': 'en-US',
'x-ms-client-request-id': '62a90ad4-daab-4022-b3be-95b03df30273',
'Content-Type': 'application/json; charset=utf-8',
'user-agent': 'Node/v6.11.5 (x64-Linux-4.4.0-98-generic) ms-rest/2.2.5 ms-rest-azure/2.4.4 azure-arm-resource/3.0.0-preview Azure-SDK-For-Node'
},
body: null
}
from azure-sdk-for-js.
Is there an API exposed in the SDK to get the tenants for an account?
Also, is there an API exposed in the SDK to get the subscriptions for a tenant?
from azure-sdk-for-js.
@omarsourour please open a new issue to track follow up questions.
I'm closing this issue now because the version relevant to the initial report should have been rolled out to all regions by now and the client updated.
from azure-sdk-for-js.
Related Issues (20)
- Dependency package @rollup/plugin-commonjs has a new version available
- Dependency package chai-as-promised has a new version available
- Dependency package nyc has a new version available
- [appconfig][react-native] Value of a key is undefined HOT 14
- InvalidHeaderValue error thrown when acquiring a blob lease HOT 4
- wrong @TextAnalysisClient import from the @azure/ai-text-analytics package in text analytics documentation HOT 2
- Cannot find module 'node:os' in @azure/logger dependency of @azure/identity HOT 8
- @azure/storage-blob version 12.23.0, problems/bug with setPlatformSpecificData function, Cannot access member 'bun' of undefined. HOT 4
- `@azure/storage-file-share` - Missing headers in REST requests HOT 7
- AutoLockRenew keeps throwing timeout exception HOT 13
- Not clear how to narrow `BuildModelDefaultResponse | BuildModelLogicalResponse` when using `await poller.pollUntilDone()` HOT 4
- [ai-document-intelligence] Loading from an ESM module still doesn't seem to work fine. Still loads CJS HOT 2
- [EngSys] configure dependabot to ignore certain directories when opening upgrade pull requests
- outputContentFormat: 'markdown' leads to some features (keyValuePairs, queryFields) silently not working anymore.
- `DocumentAnalysisClient` and `ClassifyDocumentOptions` are inconsistent over different client SDKs HOT 1
- Vitest can't pick up environment variable TEST_MODE when targeting browser HOT 4
- [test][core-amqp] unstable request response test HOT 2
- isAvailable event is being triggered after a 30-40 second delay, in ACS Room Video Call HOT 5
- [App Configuration] AppConfigurationClient - FeatureFlag FeatureFlag configuration setting "before each" hook for "can add and get FeatureFlag" failing in nightly runs HOT 1
- [Eventhubs - Checkpointstore Blob] updates checkpoints successfully failing in nightly runs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-sdk-for-js.