Giter Club home page Giter Club logo

csp-billing-adapter-microsoft's People

Contributors

brett060102 avatar jesusbv avatar keithmnemonic avatar rtamalin avatar smarlowucf avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csp-billing-adapter-microsoft's Issues

The csp-billing-adapter-microsoft needs to support Azure Managed applications

A few difference exist in how the token, resourceURI and plan are collected from a Azure Manager Kubernetes Application and a standard Azure Managed (VM).

In order for the token to be retrieved, the VM must have Azure System Identity assigned

https://learn.microsoft.com/en-us/partner-center/marketplace/marketplace-metering-service-authentication#using-the-azure-managed-identities-token

  1. For the Managed Application, the token needs to be acquired by using resource=https://management.azure.com and not needing a client id https://github.com/SUSE-Enceladus/csp-billing-adapter-microsoft/blob/main/csp_billing_adapter_microsoft/plugin.py#L211

  2. I believe the method for getting the planID can leverage the metadata as it has some "plan" data in the metadata.

{"compute":{"azEnvironment":"AzurePublicCloud","customData":"","location":"eastus","name":"linux-vm","offer":"manager-server-4-3-llc-image","osType":"Linux","placementGroupId":"","plan":{"name":"gen2","product":"manager-server-4-3-llc-image","publisher":"suse"}
  1. The resourceURI should be able to be retrieved by getting the managedBy field from following the example at the URL above.

"https://management.azure.com/subscriptions/" + $metadata.compute.subscriptionId + "/resourceGroups/" + $metadata.compute.resourceGroupName + "?api-version=2019-10-01"

but for some reason, even with a managed identity assigned I am getting

{"error":{"code":"AuthorizationFailed","message":"The client 'XXXXXXXXXXXXXX' with object id 'XXXXXXXXXXXXXXXXX' does not have authorization to perform action 'Microsoft.Resources/subscriptions/resourceGroups/read' over scope '/subscriptions/XXXXXXXXXXX/resourceGroups/mrg-manager-server-4-3-llc-preview-20231006090809' or the scope is invalid. If access was recently granted, please refresh your credentials."}}

This will need to be figured out.

  1. A check will have to be added to determine if this is running in local vs k8s and then use the alternate path to obtains the token, planId and "resourceId" needed for request body.
{
  "resourceId": <guid>, // unique identifier of the resource against which usage is emitted. 
  "quantity": 5.0, // how many units were consumed for the date and hour specified in effectiveStartTime, must be greater than 0 or a double integer
  "dimension": "dim1", // custom dimension identifier
  "effectiveStartTime": "2018-12-01T08:30:14", // time in UTC when the usage event occurred, from now and until 24 hours back
  "planId": "plan1", // id of the plan purchased for the offer
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.