Skip to content
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

Super level API #1224

Closed
sura2k opened this issue Oct 21, 2016 · 7 comments
Closed

Super level API #1224

sura2k opened this issue Oct 21, 2016 · 7 comments
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library.
Milestone

Comments

@sura2k
Copy link

sura2k commented Oct 21, 2016

Is there a way to

  • Retrieve tenant information (i.e tenant id)
  • Get VM information by passing tenant id (or any other way)
  • Get storage details by tenant

Via super level API (with super level API access key)?

My requirement is to view/show usage details by tenant for managing level people.
Can I do that using this SDK? If not, does Azure Server support this facility?

@jianghaolu
Copy link
Contributor

Assuming you are using 1.0.0-beta2 onward.

  1. before call .withSubscription() you will get an Azure.Authenticated object. You can call .tenants() on it.
    2, 3) Storage accounts and VMs are under subscriptions and resource groups. You will need at least subscription information to list them.

So you will need to

  1. list all the tenants
  2. For each tenant, create a credential and login and list subscriptions
  3. For each subscription, you can list all the resources you want

Let me know if you need further help. I may be able to write a sample in a few weeks.

@sura2k
Copy link
Author

sura2k commented Oct 21, 2016

  1. For each tenant, create a credential and login and list subscriptions

What is meant by "create a credential and login"? A tenet already has a login, right?

I may be able to write a sample in a few weeks.

Which is Great 👍

The above mentioned 3 operations, list tenants, get vm info, get storage info are just few from the actual requirements. These are for a read only application.

Still little bit unclear about the authentication.
I except to have some sort of a login/API Key which has access to all tenant related operations.
By looking at the following code snippet, I can see a tenantparameter is getting passed into the API.
So the tenant I'm referring here is some kind of a SUPER tenant with higher access level rather than a regular tenant?

ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(client, tenant, key, AzureEnvironment.AZURE);
Azure azure = Azure.authenticate(credentials);

Thanks for your quick response :)

@sura2k
Copy link
Author

sura2k commented Oct 21, 2016

Also I found this: Using a RestClient I can get Azureobject by tenantId.
I'm looking something similar to this.
So my questions are,

  1. That super (the variabale) really returns all the tenet Ids?
  2. If I know the tenet id list, following code will work?
Authenticated super= Azure.authenticate(...);

for(Tenant tenant: super.tenants().list()){
    String tenantId = tenant.inner().tenantId();

    RestClient restClient = AzureEnvironment.AZURE.newRestClientBuilder().build();
    Authenticated restAuth = Azure.authenticate(restClient, tenantId);
    Azure azureTenent = restAuth.withDefaultSubscription();

    //process each tenant
 }

@martinsawicki martinsawicki added this to the Backlog milestone Oct 9, 2017
@praries880 praries880 added the Mgmt This issue is related to a management-plane library. label Nov 14, 2018
sima-zhu pushed a commit to sima-zhu/azure-sdk-for-java that referenced this issue Mar 21, 2019
@joshfree joshfree removed this from the Sprint : 1/28/2019 - 2/15/2019 milestone Oct 2, 2019
@yungezz yungezz added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Apr 17, 2020
@yungezz yungezz added this to the Sprint 169 milestone Apr 20, 2020
@yungezz
Copy link
Member

yungezz commented Apr 20, 2020

hi @weidongxu-microsoft could you pls have a look? thanks.

@weidongxu-microsoft
Copy link
Member

weidongxu-microsoft commented Apr 21, 2020

I think current Java SDK does not support multi-tenant as common authentications.

However if one have a Azure CLI logged-in, one can use AzureCliCredentials to list available multi-tenants.

            Azure.Authenticated authenticated = Azure.configure()
                    .withLogLevel(LogLevel.BASIC)
                    .authenticate(AzureCliCredentials.create());
            PagedList<Tenant> tenants = authenticated.tenants().list();
            for (Tenant tenant : tenants) {
                ...
            }

However for each tenant, one likely still need separate credentials to authenticate again.

@xccc-msft Let me know if you have insight on this.

@yungezz
Copy link
Member

yungezz commented Apr 29, 2020

hi @sura2k does above info helpful? let us know if you met issue when using it.

@yungezz
Copy link
Member

yungezz commented Apr 30, 2020

hi @sura2k pls try above AzureCliCredentials and feel free to create new issue if met any error. Will close the issue for now. thanks.

@yungezz yungezz closed this as completed Apr 30, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library.
Projects
None yet
Development

No branches or pull requests

7 participants