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)
- [core] core-client-rest `PathUnchecked` does not infer path parameters which are not preceded by `/`
- read ECONNRESET when trying to stream GPT response with a PTU deployment HOT 4
- `@azure/monitor-opentelemetry` ignoes AZURE_LOG_LEVEL setting when `APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL` is not set
- TS2305: Module '"@azure/openai"' has no exported member 'AzureKeyCredential'. HOT 4
- ResourceNotFound error when connecting to Azure OpenAI using latest JavaScript SDK (version 2.0.0-beta.1) HOT 3
- [Core] add ResourceId support
- Ali963.sy
- Refresh all the rlc sdks in sdk repo HOT 5
- can not validate the authority HOT 2
- How to use aggregation with @azure/cosmos in nosql database HOT 2
- Unable to resolve module crypto - @azure/notification-hubs HOT 1
- [feature request] adding `generateSasStringToSign` for other packages
- [Service Bus] PartitionedSubscriptionWithSessions: deleteMessages (session) failing in nightly runs HOT 2
- [Storage - File Datalake] macoslatest_224x_node failing in nightly runs
- Dependency package puppeteer has a new version available HOT 1
- Dependency of @azure/core-xml has vulnerability CVE-2024-41818 HOT 3
- Regenerate Azure AI Search with latest Swagger
- [core] Copy changes for refresh_on support to ts-http-runtime
- unable to specify stream_options for completions method HOT 1
- ability to specifiy search_type and embedding endpoint in the v4 HOT 6
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.