Skip to main content

CSP Billing Adapter Microsoft Plugin

This is a plugin for csp-billing-adapter that provides CSP hook implementations. This includes the hooks defined in the csp_hookspecs.py module.

Meter billing

The meter_billing function accepts a dictionary mapping of dimension name to usage quantity. This information is used to bill the customer for the product ID that is configured in the adapter. If there is an exception with metered billing the exception is raised.

Get CSP Name

The get_csp_name function returns the name of the CSP provider. In this case it is microsoft.

Get Account Info

The get_account_info function provides metadata information for the running instance or container. The structure of this information is as follows:

{
    "compute": {
        "azEnvironment": "AzurePublicCloud",
        "customData": "",
        "isHostCompatibilityLayerVm": "false",
        "licenseType": "",
        "location": "eastus",
        "name": "csp-adapter-test",
        "offer": "sles-15-sp4-byos",
        "osProfile": {
            "adminUsername": "foo",
            "computerName": "csp-adapter-test"
        },
        "osType": "Linux",
        "placementGroupId": "",
        "plan": {
            "name": "",
            "product": "",
            "publisher": ""
        },
        "platformFaultDomain": "0",
        "platformUpdateDomain": "0",
        "provider": "Microsoft.Compute",
        "publicKeys": [
            {
                "keyData": ssh_public_key,
                "path": "/home/foo/.ssh/authorized_keys"
            }
        ],
        "publisher": "suse",
        "resourceGroupName": "foo",
        "resourceId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/foo/providers/Microsoft.Compute/virtualMachines/csp-adapter-test",
        "securityProfile": {
            "secureBootEnabled": "false",
            "virtualTpmEnabled": "false"
        },
        "sku": "gen2",
        "storageProfile": {
            "dataDisks": [],
            "imageReference": {
                "id": "",
                "offer": "sles-15-sp4-byos",
                "publisher": "suse",
                "sku": "gen2",
                "version": "2023.05.06"
            },
            "osDisk": {
                "caching": "ReadWrite",
                "createOption": "FromImage",
                "diffDiskSettings": {
                    "option": ""
                },
                "diskSizeGB": "30",
                "encryptionSettings": {
                    "enabled": "false"
                },
                "image": {
                    "uri": ""
                },
                "managedDisk": {
                    "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/foo/providers/Microsoft.Compute/disks/csp-adapter-test_Os_Disk_1_12345678901234567890",
                    "storageAccountType": "Premium_LRS"
                },
                "name": "csp-adapter-test_Os_Disk_1_12345678901234567890",
                "osType": "Linux",
                "vhd": {
                    "uri": ""
                },
                "writeAcceleratorEnabled": "false"
            }
        },
        "subscriptionId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "tags": "Cost Center:123456789;Department:foo;Environment:foo;Finance Business Partner:foo;General Ledger Code:123456789;Group:foo;Owner:foo;Stakeholder:foo",
        "tagsList": [
            {
                "name": "Cost Center",
                "value": "12345678"
            },
            {
                "name": "Department",
                "value": "foo"
            },
            {
                "name": "Environment",
                "value": "foo"
            },
            {
                "name": "Finance Business Partner",
                "value": "foo"
            },
            {
                "name": "General Ledger Code",
                "value": "123456789"
            },
            {
                "name": "Group",
                "value": "foo"
            },
            {
                "name": "Owner",
                "value": "foo"
            },
            {
                "name": "Stakeholder",
                "value": "foo"
            }
        ],
        "version": "2023.05.06",
        "vmId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "vmScaleSetName": "",
        "vmSize": "Standard_B2s",
        "zone": ""
    },
    "network": {
        "interface": [
            {
                "ipv4": {
                    "ipAddress": [
                        {
                            "privateIpAddress": "10.0.0.8",
                            "publicIpAddress": "192.168.1.1"
                        }
                    ],
                    "subnet": [
                        {
                            "address": "10.0.0.0",
                            "prefix": "24"
                        }
                    ]
                },
                "ipv6": {
                    "ipAddress": []
                },
                "macAddress": "123456789ABCD"
            }
        ]
    },
    "attestedData": {
        "encoding": "pkcs7",
        "signature": signature
    },
    "cloud_provider": "microsoft"
}

This information is pulled from the Azure Instance metadata endpoint: http://169.254.169.254/metadata/instance?api-version=2021-02-01. Note: the exact information in the document entry may vary.

Release files for csp-billing-adapter-microsoft 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for csp-billing-adapter-microsoft 1.3.1
File Size Uploaded
csp_billing_adapter_microsoft-1.3.1.tar.gz 17.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for csp-billing-adapter-microsoft 1.3.1
File Interpreter ABI Platform
csp_billing_adapter_microsoft-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 29.3 kB

Release files / csp_billing_adapter_microsoft-1.3.1.tar.gz

Download URL csp_billing_adapter_microsoft-1.3.1.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2ded3903f1ab1778025a4fdc5cdf6bfcdb402ca149d1649f2fa2f78f15ef2de0
BLAKE2b-256 checksum
How to use checksums
2927b7836a4e24b59fb193e9cb3f57c6dfe5d6fc89cb8076c1be6b62f6f8099a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 8, 2026.

Transparency log

Release files / csp_billing_adapter_microsoft-1.3.1-py3-none-any.whl

Download URL csp_billing_adapter_microsoft-1.3.1-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
61ea73986aab2edfa354187626e073e0cb0b97073c94cb25f45ddc223dd62dfd
BLAKE2b-256 checksum
How to use checksums
2fc6d12b4760626cba97489d7768cd596ab5e480d31028dcfdb65cc259647248
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.3.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page