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

Method to retrieve remaining API credits #26

Open
erikcw opened this issue Apr 11, 2017 · 2 comments
Open

Method to retrieve remaining API credits #26

erikcw opened this issue Apr 11, 2017 · 2 comments

Comments

@erikcw
Copy link

erikcw commented Apr 11, 2017

Would be handy to have a method to retrieve the remaining API credits for an account.

@tristantao
Copy link
Owner

That makes sense.

Unfortunately I can't find an API offering from Microsoft that allows for that. Let me know if you know of an endpoint / doc they offer that allows the users to get remaining credits.

@rtruxal
Copy link
Contributor

rtruxal commented Sep 7, 2017

I'm pretty familiar with the Azure RM interface and this issue is probably not practical to solve. :[

In order to accomplish this in python one would need to use the azure resource-manager (pip install azurerm). The API-key you use here gives you access to a single, specific REST interface for interacting with the search engine. Since controls for & statistics on your various Azure-resources are implemented at the subscription-level, the API-key you're currently using with this package would not be sufficient to authenticate you.
This is primarily due to some prep-work necessary to use azurerm in the first place:

To use the azurerm python SDK you need to integrate an "app" with Azure Active Directory:

To see your usage statistics outside of the Azure Dashboard you'll need to either use PowerShell (which has authentication baked-in to it's SDK,) or register some sort of authentication-mechanism with your AAD tenant. The easiest way to do this is to register a "service principal" via the Azure Active Directory pane at https://portal.azure.com. This will give you 3 new "keys" needed each time you want to authenticate:

  • the "app"'s tenant id.
  • your Azure subscription-ID
  • a secret code it gives you at registration time.

after that...welll there's probably some rabbit-hole of commands which would find that specific piece of info. It's probably somewhere in here: https://github.com/Azure/azure-sdk-for-python/tree/master/azure-mgmt-cognitiveservices

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants