Skip to content

_azure

sc_crawler.vendors._azure #

Inventory of Microsoft Azure via its APIs: servers, storages, traffic, IPv4 addresses and managed PostgreSQL (Flexible Server), with their prices.

Functions:

Name Description
inventory_compliance_frameworks

Manual list of known compliance frameworks at Azure.

inventory_regions

List all regions via API call.

inventory_zones

List all availability zones.

inventory_servers

List all available instance types in all regions.

inventory_server_prices

List all known server ondemand prices in all regions using the Azure Retail Pricing API.

inventory_server_prices_spot

List all known server spot prices in all regions using the Azure Retail Pricing API.

inventory_storages

List all storage options via the Compute resource manager client.

inventory_storage_prices

Look up Storage prices via the Azure Retail Prices API.

inventory_traffic_prices

Look up Internet Egress/Ingress prices via the Azure Retail Prices API.

inventory_ipv4_prices

Look up Internet Egress/Ingress prices via the Azure Retail Prices API.

inventory_databases

List Azure Database for PostgreSQL Flexible Server types in all regions.

inventory_database_prices

List Azure Database for PostgreSQL Flexible Server on-demand prices from the Retail Pricing API.

inventory_database_storages

List all Azure Database for PostgreSQL Flexible Server storage options via the capabilities API.

inventory_database_storage_prices

Look up Azure Database for PostgreSQL Flexible Server storage prices via the Azure Retail Prices API.

Attributes:

Name Type Description
SERVER_FEATURES

Map lowercase chars from the server name to features.

STORAGE_PRICE_UNIT_MAPPING dict[str, float | None]

Storage capacity units → multiplier to convert the raw API price to $/GB/month.

SERVER_FEATURES module-attribute #

SERVER_FEATURES = {'a': 'AMD processor', 'p': 'ARM processor', 'b': 'Block Storage performance', 'd': 'Local Disk', 'i': 'Isolated', 'l': 'Low Memory', 'm': 'Memory Intensive', 'n': 'Network Optimized', 't': 'Tiny Memory', 's': 'Premium Storage capable', 'r': 'RDMA capable', 'e': 'Memory Optimized', 'x': 'Unmatched Memory Capacity', 'o': 'o'}

Map lowercase chars from the server name to features.

STORAGE_PRICE_UNIT_MAPPING module-attribute #

STORAGE_PRICE_UNIT_MAPPING = {'1/Month': None, '1 GiB/Month': 1 / _GIB_TO_GB, '1 GB/Month': 1.0, '1 GiB/Hour': _HOURS_PER_MONTH / _GIB_TO_GB, '1 GB/Hour': _HOURS_PER_MONTH}

Storage capacity units → multiplier to convert the raw API price to $/GB/month.

inventory_compliance_frameworks #

inventory_compliance_frameworks(vendor)

Manual list of known compliance frameworks at Azure.

Data collected from https://learn.microsoft.com/en-us/azure/compliance/.

Source code in sc_crawler/vendors/_azure.py
def inventory_compliance_frameworks(vendor):
    """Manual list of known compliance frameworks at Azure.

    Data collected from <https://learn.microsoft.com/en-us/azure/compliance/>.
    """
    return map_compliance_frameworks_to_vendor(
        vendor.vendor_id, ["hipaa", "soc2t2", "iso27001"]
    )

inventory_regions #

inventory_regions(vendor)

List all regions via API call.

Location (country and state) and founding year were collected manually from https://datacenters.microsoft.com/globe/explore/ and its underlying JSON at https://datacenters.microsoft.com/globe/data/geo/regions.json.

City and the energy source information was collected from the sustainability fact sheets referenced in the above page and JSON.

Coordinates were provided by the Microsoft API, which doesn't seem to be very reliable.

Some regions are restricted to specific customer scenarios, such as disaster recovery within a geography (e.g. australiacentral2, brazilsoutheast, germanynorth, norwaywest, southafricawest, uaecentral, swedensouth), see https://learn.microsoft.com/en-us/azure/reliability/regions-list. These are listed if visible to the subscription, but services and SKUs are usually not available there without a region access request: https://learn.microsoft.com/en-us/troubleshoot/azure/general/region-access-request-process.

Source code in sc_crawler/vendors/_azure.py
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
def inventory_regions(vendor):
    """List all regions via API call.

    Location (country and state) and founding year
    were collected manually from
    <https://datacenters.microsoft.com/globe/explore/>
    and its underlying JSON at
    <https://datacenters.microsoft.com/globe/data/geo/regions.json>.

    City and the energy source information was collected from
    the sustainability fact sheets referenced in the above page and JSON.

    Coordinates were provided by the Microsoft API, which doesn't seem
    to be very reliable.

    Some regions are restricted to specific customer scenarios, such as
    disaster recovery within a geography (e.g. `australiacentral2`,
    `brazilsoutheast`, `germanynorth`, `norwaywest`, `southafricawest`,
    `uaecentral`, `swedensouth`), see
    <https://learn.microsoft.com/en-us/azure/reliability/regions-list>.
    These are listed if visible to the subscription, but services and SKUs
    are usually not available there without a region access request:
    <https://learn.microsoft.com/en-us/troubleshoot/azure/general/region-access-request-process>.
    """

    manual_datas = {
        # Canada
        "canadaeast": {
            "country_id": "CA",
            "state": "Quebec",
            "city": "Quebec City",
            "founding_year": 2016,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "canadacentral": {
            "country_id": "CA",
            "city": "Toronto",
            "founding_year": 2016,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        # United States
        "centralus": {
            "country_id": "US",
            "state": "Iowa",
            "founding_year": 2014,
            "green_energy": True,
        },
        "centraluseuap": {
            "country_id": "US",
            "state": "Iowa",
            "green_energy": True,
        },
        "eastus": {
            "country_id": "US",
            "city": "Boydton",
            "state": "Virginia",
            # official site says 2014 with a dead link, but it was 2012 as per
            # https://web.archive.org/web/20120530115120/http:/blogs.msdn.com/b/windowsazure/archive/2012/04/05/announcing-new-datacenter-options-for-windows-azure.aspx
            "founding_year": 2012,
            "green_energy": False,
        },
        "eastusstg": {
            "country_id": "US",
            "state": "Virginia",
            "green_energy": False,
        },
        "eastus2": {
            "country_id": "US",
            "city": "Boydton",
            "state": "Virginia",
            # official site says 2012 with a dead link, but it was 2014 as per
            # https://azure.microsoft.com/en-us/updates/general-availability-microsoft-azure-us-central-and-us-east-2-regions/
            "founding_year": 2014,
            "green_energy": False,
        },
        "eastus2euap": {
            "country_id": "US",
            "state": "Virginia",
            "green_energy": False,
        },
        "northcentralus": {
            "country_id": "US",
            "city": "Chicago",
            "state": "Illinois",
            "founding_year": 2009,
            "green_energy": False,
        },
        "southcentralus": {
            "country_id": "US",
            "state": "Texas",
            "city": "San Antonio",
            "founding_year": 2008,
            "green_energy": True,
        },
        "southcentralusstg": {
            "country_id": "US",
            "state": "Texas",
            "city": "San Antonio",
        },
        "westcentralus": {
            "country_id": "US",
            "state": "Wyoming",
            "city": "Cheyenne",
            "founding_year": 2016,
            "green_energy": False,
        },
        "westus": {
            "country_id": "US",
            "state": "California",
            "founding_year": 2012,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "westus2": {
            "country_id": "US",
            "state": "Washington",
            "founding_year": 2007,
            "green_energy": False,
        },
        "westus3": {
            "country_id": "US",
            "state": "Arizona",
            "city": "Phoenix",
            "founding_year": 2021,
            "green_energy": False,
        },
        # Mexico
        "mexicocentral": {
            "country_id": "ZA",
            "state": "Querétaro",
            "founding_year": 2024,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        # South America
        "brazilsouth": {
            "country_id": "BR",
            "state": "Campinas",
            "founding_year": 2014,
            "green_energy": False,
        },
        "brazilsoutheast": {
            "country_id": "US",
            "city": "Rio de Janeiro",
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "chilecentral": {
            "country_id": "CL",
            "city": "Santiago",
            # coming soon
            "founding_year": 2025,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        # not production region?
        # https://github.com/Azure/azure-dev/issues/2165#issuecomment-1542948509
        "brazilus": {
            "country_id": "BR",
        },
        # Asia Pacific
        "australiacentral": {
            "country_id": "AU",
            "city": "Canberra",
            "founding_year": 2018,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "australiacentral2": {
            "country_id": "AU",
            "city": "Canberra",
            "founding_year": 2018,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "australiaeast": {
            "country_id": "AU",
            "city": "Sydney",
            "state": "New South Wales",
            "founding_year": 2014,
            "green_energy": False,
        },
        "australiasoutheast": {
            "country_id": "AU",
            "city": "Melbourne",
            "state": "Victoria",
            "founding_year": 2014,
            "green_energy": False,
        },
        "eastasia": {
            "country_id": "HK",
            "founding_year": 2010,
            "green_energy": False,
        },
        "southeastasia": {
            "country_id": "SG",
            "city": "Singapore",
            "founding_year": 2010,
            "green_energy": False,
        },
        # second Malaysian region (paired with malaysiawest), still rolling out
        "southeastasia3": {
            "country_id": "MY",
            "city": "Johor Bahru",
            "state": "Johor",
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        # city as per the Azure regions list, exact site not disclosed by Microsoft
        "taiwannorth": {
            "country_id": "TW",
            "city": "Taipei",
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "japaneast": {
            "country_id": "JP",
            "city": "Tokyo",
            "founding_year": 2014,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "japanwest": {
            "country_id": "JP",
            "city": "Osaka",
            "founding_year": 2014,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "jioindiacentral": {
            "country_id": "IN",
            "city": "Nagpur",
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "jioindiawest": {
            "country_id": "IN",
            "city": "Jamnagar",
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "centralindia": {
            "country_id": "IN",
            "state": "Pune",
            "founding_year": 2015,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "southindia": {
            "country_id": "IN",
            "state": "Chennai",
            "founding_year": 2015,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "indiasouthcentral": {
            "country_id": "IN",
            "state": "Telangana",
            "city": "Hyderabad",
            # coming soon; targeted mid-2026 (Microsoft Source Asia, Dec 2025)
            "founding_year": 2026,
            # no region-specific sustainability fact sheet yet
            "green_energy": False,
        },
        "westindia": {
            "country_id": "IN",
            "state": "Mumbai",
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "koreacentral": {
            "country_id": "KR",
            "city": "Seoul",
            "founding_year": 2017,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "koreasouth": {
            "country_id": "KR",
            "city": "Busan",
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "newzealandnorth": {
            "country_id": "NZ",
            "city": "Auckland",
            "founding_year": 2024,
            "green_energy": False,
        },
        "indonesiacentral": {
            "country_id": "ID",
            "city": "Jakarta",
            # coming soon
            "founding_year": 2025,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "malaysiawest": {
            "country_id": "MY",
            "city": "Kuala Lumpur",
            # coming soon
            "founding_year": 2025,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        # Europe
        "denmarkeast": {
            "country_id": "DK",
            "city": "Copenhagen",
            "founding_year": 2026,
            # https://news.microsoft.com/source/emea/features/accelerating-europes-digital-future-microsoft-announces-plans-for-a-new-datacenter-region-in-west-denmark
            "green_energy": True,
        },
        "francecentral": {
            "country_id": "FR",
            "city": "Paris",
            "founding_year": 2018,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "francesouth": {
            "country_id": "FR",
            "city": "Marseille",
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "germanynorth": {
            "country_id": "DE",
            "city": "Berlin",
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "germanywestcentral": {
            "country_id": "DE",
            "city": "Frankfurt",
            "founding_year": 2019,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "italynorth": {
            "country_id": "IT",
            "city": "Milan",
            "founding_year": 2023,
            "green_energy": False,
        },
        "northeurope": {
            "country_id": "IE",
            "city": "Dublin",
            "founding_year": 2009,
            "green_energy": False,
        },
        "norwayeast": {
            "country_id": "NO",
            "city": "Oslo",
            "founding_year": 2019,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "norwaywest": {
            "country_id": "NO",
        },
        "polandcentral": {
            "country_id": "PL",
            "city": "Warsaw",
            "founding_year": 2023,
            "green_energy": False,
        },
        "spaincentral": {
            "country_id": "ES",
            "city": "Madrid",
            "founding_year": 2024,
            "green_energy": False,
        },
        "swedencentral": {
            "country_id": "SE",
            "city": "Gävle and Sandviken",
            "founding_year": 2021,
            "green_energy": False,
        },
        "switzerlandnorth": {
            "country_id": "CH",
            "city": "Zürich",
            "founding_year": 2019,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "switzerlandwest": {
            "country_id": "CH",
            "city": "Geneva",
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "uksouth": {
            "country_id": "GB",
            "city": "London",
            "founding_year": 2016,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "ukwest": {
            "country_id": "GB",
            "city": "Cardiff",
            "founding_year": 2017,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "westeurope": {
            "country_id": "NL",
            "founding_year": 2010,
            "green_energy": False,
        },
        "belgiumcentral": {
            "country_id": "BE",
            "founding_year": 2025,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        # Middle East
        "israelcentral": {
            "country_id": "IL",
            "founding_year": 2023,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "qatarcentral": {
            "country_id": "QA",
            "city": "Doha",
            "founding_year": 2022,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "uaecentral": {
            "country_id": "AE",
            "city": "Abu Dhabi",
        },
        "uaenorth": {
            "country_id": "AE",
            "city": "Dubai",
            "founding_year": 2019,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "austriaeast": {
            "country_id": "AT",
            "city": "Vienna",
            "founding_year": 2025,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        # Africa
        "southafricanorth": {
            "country_id": "ZA",
            "city": "Johannesburg",
            "founding_year": 2019,
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        "southafricawest": {
            "country_id": "ZA",
            "city": "Cape Town",
            # unknown as no sustainability fact sheet found
            "green_energy": False,
        },
        # China TODO enable
    }

    items = []
    for region in _regions():
        with sentry_capture_or_raise(vendor=vendor):
            # TODO drop this once the metadata field doesn't show up randomly anymore
            # as the non-metadata responses do not seem to have these logical regions anymore
            metadata = region.get("metadata", {})
            region_type = metadata.get("regionType") or metadata.get(
                "region_type", "Physical"
            )
            if region_type != "Physical":
                continue
            # no idea what are these
            if region["name"].endswith("stg"):
                continue
            if region["name"].endswith("stage"):
                continue
            # not production region?
            # https://github.com/Azure/azure-dev/issues/2165#issuecomment-1542948509
            if region["name"] == "brazilus":
                continue
            manual_data = manual_datas.get(region["name"])
            if not manual_data:
                raise KeyError(f"No manual data found for {region['name']}.")
            # azure-mgmt-resource 25+ as_dict() uses camelCase keys (displayName)
            region_name = next(
                (region[k] for k in ("display_name", "displayName") if region.get(k)),
                region["name"],
            )
            display_name = region.get("displayName") or region.get("display_name")
            items.append(
                {
                    "vendor_id": vendor.vendor_id,
                    "region_id": region["name"],
                    "name": region_name,
                    "api_reference": region["name"],
                    "display_name": (
                        region_name + " (" + manual_data["country_id"] + ")"
                    ),
                    "aliases": [display_name] if display_name else [],
                    "country_id": manual_data["country_id"],
                    "state": manual_data.get("state"),
                    "city": manual_data.get("city"),
                    "address_line": None,
                    "zip_code": None,
                    # sometimes the API passes "metadata" and the lat/long nested, sometimes it's not
                    # TODO revisit after a few days passed since this change:
                    # https://github.com/Azure/azure-sdk-for-python/blob/azure-mgmt-resource_25.0.0/sdk/resources/azure-mgmt-resource/CHANGELOG.md#2500-2026-02-04
                    "lat": region.get("metadata", {}).get(
                        "latitude", region.get("latitude")
                    ),
                    "lon": region.get("metadata", {}).get(
                        "longitude", region.get("longitude")
                    ),
                    "founding_year": manual_data.get("founding_year"),
                    "green_energy": manual_data.get("green_energy"),
                }
            )
    return items

inventory_zones #

inventory_zones(vendor)

List all availability zones.

API call to list existing availability zones ("1", "2", and "3") for each region, and creating a dummy "0" zone for the regions without availability zones.

Source code in sc_crawler/vendors/_azure.py
def inventory_zones(vendor):
    """List all availability zones.

    API call to list existing availability zones ("1", "2", and "3")
    for each region, and creating a dummy "0" zone for the regions
    without availability zones.
    """
    items = []
    resources = _resources("Microsoft.Compute")
    locations = next(
        (
            i
            for i in resources
            if i.get("resource_type") == "virtualMachines"
            or i.get("resourceType") == "virtualMachines"
        ),
        {},
    )
    zone_mappings = locations.get("zone_mappings", locations.get("zoneMappings", []))
    locations = {item["location"]: item["zones"] for item in zone_mappings}
    for region in vendor.regions:
        # default to zone with 0 ID if there are no real availability zones
        region_zones = locations.get(region.name, ["0"])
        for zone in region_zones:
            items.append(
                {
                    "vendor_id": vendor.vendor_id,
                    "region_id": region.region_id,
                    "zone_id": zone,
                    "name": zone,
                    "api_reference": zone,
                    "display_name": region.region_id + "-" + zone,
                }
            )
    return items

inventory_servers #

inventory_servers(vendor)

List all available instance types in all regions.

Lifecycle: the retirement date of _azure_sku_retirement_date (API, then _AZURE_RETIREMENT_RULES) is stored in retirement_date — RETIRED if it has passed, PLANNED_FOR_RETIREMENT if not yet, otherwise ACTIVE.

Source code in sc_crawler/vendors/_azure.py
def inventory_servers(vendor):
    """List all available instance types in all regions.

    Lifecycle: the retirement date of `_azure_sku_retirement_date` (API, then
    `_AZURE_RETIREMENT_RULES`) is stored in `retirement_date` — RETIRED if
    it has passed, PLANNED_FOR_RETIREMENT if not yet, otherwise ACTIVE.
    """
    servers = _servers()
    for i in range(len(servers) - 1, -1, -1):
        name = servers[i].get("name")
        # drop Basic servers as to be deprecated by Aug 2024
        if name.startswith("Basic"):
            vendor.log(f"Excluding deprecated: {name}")
            servers.pop(i)
        # servers that are likely to be not available, with zero pricing
        if name.endswith("Promo"):
            vendor.log(f"Excluding nonsense pricing: {name}")
            servers.pop(i)
        # servers probably not intended for our eyes
        if "Internal" in name:
            vendor.log(f"Excluding internal server: {name}")
            servers.pop(i)
        # servers randomly switching between active/inactive status
        # TODO review from time to time
        if name in ["Standard_M896ixds_32_v3", "Standard_M64-32bds_1_v3"]:
            vendor.log(f"Excluding server with questionable availability: {name}")
            servers.pop(i)
    servers = preprocess_servers(servers, vendor, _standardize_server)
    return servers

inventory_server_prices #

inventory_server_prices(vendor)

List all known server ondemand prices in all regions using the Azure Retail Pricing API.

More information: https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices.

Source code in sc_crawler/vendors/_azure.py
def inventory_server_prices(vendor):
    """List all known server ondemand prices in all regions using the Azure Retail Pricing API.

    More information: <https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices>.
    """
    return _inventory_server_prices(vendor, Allocation.ONDEMAND)

inventory_server_prices_spot #

inventory_server_prices_spot(vendor)

List all known server spot prices in all regions using the Azure Retail Pricing API.

See details at inventory_server_prices.

Source code in sc_crawler/vendors/_azure.py
def inventory_server_prices_spot(vendor):
    """List all known server spot prices in all regions using the Azure Retail Pricing API.

    See details at [inventory_server_prices][sc_crawler.vendors._azure.inventory_server_prices].
    """
    return _inventory_server_prices(vendor, Allocation.SPOT)

inventory_storages #

inventory_storages(vendor)

List all storage options via the Compute resource manager client.

For more information, see https://learn.microsoft.com/en-us/azure/virtual-machines/disks-types.

Source code in sc_crawler/vendors/_azure.py
def inventory_storages(vendor):
    """List all storage options via the Compute resource manager client.

    For more information, see <https://learn.microsoft.com/en-us/azure/virtual-machines/disks-types>.
    """
    vendor.progress_tracker.start_task(
        name="Fetching list of compute resources", total=None
    )

    disks = []
    for resource in _compute_resources():
        if resource["resourceType"] == "disks":
            disks.append(resource)

    disks = list({d["name"]: d for d in disks}.values())
    vendor.progress_tracker.hide_task()

    items = []
    for disk in disks:

        def _search(values):
            return list_search(disk["capabilities"], "name", values)["value"]

        storage_type = (
            StorageType.HDD
            if "Standard" in disk["name"] and "SSD" not in disk["name"]
            else StorageType.SSD
        )
        redundancy_type = (
            "Locally Redundant Storage"
            if "LRS" in disk["name"]
            else "Zone-Redundant Storage"
        )
        description = f"{disk['tier']} tier {storage_type.name} ({redundancy_type})"
        storage_sizes = [
            storage[1]
            for storage in _storage_meter_mapping().values()
            if storage[0] == disk["name"]
        ]
        min_size = (
            min(storage_sizes) if len(storage_sizes) > 1 else _search("MinSizeGiB")
        )
        max_size = (
            max(storage_sizes) if len(storage_sizes) > 1 else _search("MaxSizeGiB")
        )

        items.append(
            {
                "storage_id": disk["name"],
                "vendor_id": vendor.vendor_id,
                "name": disk["name"],
                "description": description,
                "storage_type": storage_type,
                "max_iops": _search(["MaxIOpsReadWrite", "MaxIOps"]),
                "max_throughput": _search(
                    ["MaxBandwidthMBpsReadWrite", "MaxBandwidthMBps"]
                ),
                "min_size": round(int(min_size) * _GIB_TO_GB),
                "max_size": round(int(max_size) * _GIB_TO_GB),
            }
        )
    return items

inventory_storage_prices #

inventory_storage_prices(vendor)

Look up Storage prices via the Azure Retail Prices API.

For more information, see https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices.

Source code in sc_crawler/vendors/_azure.py
def inventory_storage_prices(vendor):
    """Look up Storage prices via the Azure Retail Prices API.

    For more information, see <https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices>.
    """
    vendor.progress_tracker.start_task(
        name="Fetching list of storage resources", total=None
    )
    retail_prices = []
    with sentry_capture_or_raise(vendor=vendor):
        retail_prices = _get_storage_retail_prices()
    vendor.progress_tracker.hide_task()

    if not retail_prices:
        return []

    regions = scmodels_to_dict(vendor.regions, keys=["region_id"])
    storages = scmodels_to_dict(vendor.storages, keys=["storage_id"])
    storage_meters = _storage_meter_mapping()

    prices = defaultdict(list)
    for p in retail_prices:
        mapping = storage_meters.get(p["meterName"])
        if not (
            mapping
            and mapping[0] in storages.keys()
            and p["armRegionName"] in regions.keys()
        ):
            continue

        unit = p.get("unitOfMeasure")
        if unit == "1/Month":
            # mapping[1] is disk size in GiB, convert to $/GB/month.
            price = p["retailPrice"] / mapping[1] / _GIB_TO_GB
            prices[
                (
                    vendor.vendor_id,
                    p["armRegionName"],
                    mapping[0],
                    PriceUnit.GB_MONTH,
                    p["currencyCode"],
                )
            ].append(
                PriceTier(
                    lower=0,
                    upper=round(mapping[1] * _GIB_TO_GB, 4),
                    price=round(price, 4),
                )
            )
        else:
            multiplier = STORAGE_PRICE_UNIT_MAPPING.get(unit)
            if multiplier is None:
                continue  # not a storage capacity unit
            price = p["retailPrice"] * multiplier
            prices[
                (
                    vendor.vendor_id,
                    p["armRegionName"],
                    mapping[0],
                    PriceUnit.GB_MONTH,
                    p["currencyCode"],
                )
            ].append(PriceTier(lower=0, upper=float("inf"), price=round(price, 4)))

    items = []
    for key, price_tiered in prices.items():
        vendor_id, region_id, storage_id, unit, currency = key
        if len(price_tiered) == 1:
            price = price_tiered[0].price
            price_tiered = []
        else:
            price_tiered.sort(key=lambda x: x.upper)
            lower = 0
            for price_tier in price_tiered:
                price_tier.lower = lower
                lower = price_tier.upper
            price = price_tiered[0].price  # use the price of the lowest tier

        items.append(
            {
                "vendor_id": vendor_id,
                "region_id": region_id,
                "storage_id": storage_id,
                "unit": unit,
                "price": price,
                "price_tiered": price_tiered,
                "currency": currency,
            }
        )

    return items

inventory_traffic_prices #

inventory_traffic_prices(vendor)

Look up Internet Egress/Ingress prices via the Azure Retail Prices API.

For more information, see https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices.

Source code in sc_crawler/vendors/_azure.py
def inventory_traffic_prices(vendor):
    """Look up Internet Egress/Ingress prices via the Azure Retail Prices API.

    For more information, see <https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices>.
    """

    def get_tiers(prices: List[dict]) -> List[dict]:
        def prep_tiers(d: dict) -> dict:
            return {
                "lower": d.get("tierMinimumUnits", 0),
                "price": d["retailPrice"],
            }

        tiers = [prep_tiers(p) for p in prices]
        tiers.sort(key=lambda x: x.get("lower"))
        for i in range(len(tiers)):
            if i == len(tiers) - 1:
                tiers[i]["upper"] = "Infinity"
            else:
                tiers[i]["upper"] = tiers[i + 1]["lower"]
        return tiers

    def by_region(prices: List[dict], region: str) -> List[dict]:
        return [p for p in prices if p["armRegionName"] == region]

    vendor.progress_tracker.start_task(
        name="Fetching list of traffic prices", total=None
    )
    inbound_prices = []
    outbound_prices = []
    with sentry_capture_or_raise(vendor=vendor):
        inbound_prices = _get_inbound_traffic_retail_prices()
        outbound_prices = _get_outbound_traffic_retail_prices()
    vendor.progress_tracker.hide_task()

    if not inbound_prices and not outbound_prices:
        return []

    items = []
    regions = scmodels_to_dict(vendor.regions, keys=["api_reference"])
    for region in regions.values():
        for direction in ["inbound", "outbound"]:
            prices = inbound_prices if direction == "inbound" else outbound_prices
            tiers = get_tiers(by_region(prices, region.api_reference))
            if tiers:
                items.append(
                    {
                        "vendor_id": vendor.vendor_id,
                        "region_id": region.region_id,
                        "price": max([float(t["price"]) for t in tiers]),
                        "price_tiered": tiers,
                        "currency": prices[0].get("currencyCode", "USD"),
                        "unit": PriceUnit.GB_MONTH,
                        "direction": (
                            TrafficDirection.IN
                            if direction == "inbound"
                            else TrafficDirection.OUT
                        ),
                    }
                )
    return items

inventory_ipv4_prices #

inventory_ipv4_prices(vendor)

Look up Internet Egress/Ingress prices via the Azure Retail Prices API.

For more information, see https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices.

Source code in sc_crawler/vendors/_azure.py
def inventory_ipv4_prices(vendor):
    """Look up Internet Egress/Ingress prices via the Azure Retail Prices API.

    For more information, see <https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices>.
    """

    vendor.progress_tracker.start_task(
        name="Fetching list of traffic prices", total=None
    )
    prices = []
    with sentry_capture_or_raise(vendor=vendor):
        prices = _get_ipv4_retail_prices()
    vendor.progress_tracker.hide_task()

    if not prices:
        return []

    items = []
    regions = scmodels_to_dict(vendor.regions, keys=["api_reference"])
    for region in regions.values():
        price = list_search(prices, "armRegionName", region.api_reference)
        if price:
            items.append(
                {
                    "vendor_id": vendor.vendor_id,
                    "region_id": region.region_id,
                    "price": float(price["retailPrice"]),
                    "currency": price.get("currencyCode", "USD"),
                    "unit": PriceUnit.HOUR,
                }
            )
    return items

inventory_databases #

inventory_databases(vendor)

List Azure Database for PostgreSQL Flexible Server types in all regions.

Existence comes from Flexible Server capabilities (supportedServerSkus) plus concrete Retail Standard_* meters only for series already seen in capabilities (quota-hidden sizes within a real family). Per-vCore series meters are pricing-only and must not invent VM catalog sizes (e.g. DCasv5 / Dsv6 vs deployable DCadsv5 / Ddsv6).

SKUs with securityProfile ConfidentialVM are kept only when capabilities list them in an ACC region (West Europe / UAE North): other regions can advertise the same profile for non-startable shapes (e.g. Korea Central DCadsv6) with no status/reason distinguishing them. SKUs with an explicit disabled capability status are skipped. When database_id is in capabilities, those supply vCPUs, memory, HA, engine versions, storage bounds, and autotuning; otherwise edition defaults apply and vCPUs/memory come from the matching VM.

Source code in sc_crawler/vendors/_azure.py
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
def inventory_databases(vendor):
    """List Azure Database for PostgreSQL Flexible Server types in all regions.

    Existence comes from Flexible Server capabilities (``supportedServerSkus``)
    plus concrete Retail ``Standard_*`` meters only for series already seen in
    capabilities (quota-hidden sizes within a real family). Per-vCore series
    meters are pricing-only and must not invent VM catalog sizes (e.g. ``DCasv5``
    / ``Dsv6`` vs deployable ``DCadsv5`` / ``Ddsv6``).

    SKUs with ``securityProfile`` ConfidentialVM are kept only when capabilities
    list them in an ACC region (West Europe / UAE North): other regions can
    advertise the same profile for non-startable shapes (e.g. Korea Central
    ``DCadsv6``) with no ``status``/``reason`` distinguishing them. SKUs with an
    explicit disabled capability status are skipped. When ``database_id`` is in
    capabilities, those supply vCPUs, memory, HA, engine versions, storage
    bounds, and autotuning; otherwise edition defaults apply and vCPUs/memory
    come from the matching VM.
    """
    # database_id -> fields that actually come from capabilities.
    caps_by_id: dict[str, dict] = {}
    caps_locations: dict[str, set[str]] = defaultdict(set)
    edition_caps: dict[str, dict] = {}
    # edition -> storage types available in any of the regions
    storage_ids_by_edition: dict[str, set[str]] = defaultdict(set)
    retail_concrete: dict[str, str] = {}
    servers_by_id = {}
    for server in vendor.servers:
        name = server.api_reference
        if not name or "-" in name:
            continue
        servers_by_id[name] = server

    capabilities_seen = 0
    regions = _pg_database_regions(vendor)
    vendor.progress_tracker.start_task(
        name="Scanning region(s) for database(s)", total=len(regions)
    )
    for region in regions:
        location = region.api_reference
        with sentry_capture_or_raise(vendor=vendor):
            for capability in _pg_capabilities(location):
                capabilities_seen += 1
                features = {
                    getattr(feature, "name", None): getattr(feature, "status", None)
                    == "Enabled"
                    for feature in getattr(capability, "supportedFeatures", None) or []
                }
                shared = {
                    "engine_versions": _pg_engine_versions(capability),
                    "storage_extra_autosize": {"Enabled": True, "Disabled": False}.get(
                        getattr(capability, "storageAutoGrowthSupported", None),
                        features.get("StorageAutoGrowth"),
                    ),
                    # IndexTuning → advice; AdaptiveAutoVacuumAutoApply → apply (vacuum GUCs).
                    # ConfigTuning may be Writes tuning, but it's not documented.
                    # https://learn.microsoft.com/en-us/azure/postgresql/monitor/concepts-autonomous-tuning
                    # https://learn.microsoft.com/en-us/azure/postgresql/monitor/concepts-adaptive-autovacuum
                    # https://learn.microsoft.com/en-us/azure/postgresql/monitor/concepts-intelligent-tuning
                    "autotuning_advice": features.get("IndexTuning", False),
                    "autotuning_apply": features.get(
                        "AdaptiveAutoVacuumAutoApply", False
                    ),
                }
                for edition in (
                    getattr(capability, "supportedServerEditions", None) or []
                ):
                    # Azure storageSizeMb values are MiB.
                    # Premium SSD v2 is General Purpose and Memory Optimized only, Burstable is capped by Premium SSD (~32 TiB).
                    # https://learn.microsoft.com/en-us/azure/postgresql/compute-storage/concepts-storage-premium-ssd-v2
                    sizes_gb = [
                        round(int(size_mb) / 1024 * _GIB_TO_GB)
                        for storage_edition in _pg_supported_storage_editions(edition)
                        for storage_mb in (
                            getattr(storage_edition, "supportedStorageMb", None) or []
                        )
                        for size_mb in (
                            getattr(storage_mb, "storageSizeMb", None),
                            getattr(storage_mb, "maximumStorageSizeMb", None),
                        )
                        if size_mb is not None
                    ]
                    storage_ids_by_edition[edition.name] |= _pg_edition_storage_ids(
                        edition
                    )
                    shared["storage_extra_min"] = min(sizes_gb, default=None)
                    shared["storage_extra_max"] = max(sizes_gb, default=None)
                    for sku in getattr(edition, "supportedServerSkus", None) or []:
                        status = getattr(sku, "status", None)
                        if (
                            status
                            and str(status).lower().replace("_", "")
                            in _PG_CAPABILITY_DISABLED_STATUSES
                        ):
                            continue
                        # https://learn.microsoft.com/en-us/azure/postgresql/high-availability/concepts-high-availability
                        # Burstable does not support HA (the API may still list modes).
                        ha_modes = {
                            getattr(mode, "value", str(mode))
                            for mode in getattr(sku, "supportedHaMode", None) or []
                        }
                        ha = [DatabaseHaLevel.NONE]
                        if edition.name != "Burstable":
                            if "ZoneRedundant" in ha_modes:
                                ha.append(DatabaseHaLevel.MULTI_ZONE)
                            if "SameZone" in ha_modes:
                                ha.append(DatabaseHaLevel.SINGLE_ZONE)
                        ha_strategy = [DatabaseHaStrategy.NONE]
                        if len(ha) > 1:
                            ha_strategy.append(DatabaseHaStrategy.PASSIVE_STANDBY)
                        previous = caps_by_id.get(sku.name)
                        if previous and DatabaseHaLevel.MULTI_ZONE in previous["ha"]:
                            ha = previous["ha"]
                        else:
                            ha = DatabaseHaLevel.ordered(ha)
                        security_profile = getattr(
                            sku, "securityProfile", None
                        ) or getattr(sku, "security_profile", None)
                        facts = {
                            **shared,
                            "edition": edition.name,
                            "vcpus": int(sku.vCores) if sku.vCores else None,
                            "memory_amount": (
                                int(sku.supportedMemoryPerVcoreMb * sku.vCores)
                                if sku.vCores and sku.supportedMemoryPerVcoreMb
                                else None
                            ),
                            "ha": ha,
                            "ha_strategy": DatabaseHaStrategy.ordered(ha_strategy),
                            # https://learn.microsoft.com/en-us/azure/reliability/reliability-database-postgresql
                            "sla": (
                                99.99
                                if DatabaseHaLevel.MULTI_ZONE in ha
                                else 99.95
                                if DatabaseHaLevel.SINGLE_ZONE in ha
                                else 99.9
                            ),
                            "security_profile": security_profile
                            or (previous or {}).get("security_profile"),
                        }
                        caps_by_id[sku.name] = facts
                        caps_locations[sku.name].add(location)
                        edition_caps[edition.name] = facts
        with sentry_capture_or_raise(vendor=vendor):
            for item in _pg_retail_prices(location):
                product = item.get("productName", "")
                product_l = product.lower()
                if (
                    "compute" not in product_l
                    or "cosmos" in product_l
                    or "single server" in product_l
                    or not (
                        "flexible server" in product_l or "flex server" in product_l
                    )
                ):
                    continue
                arm = item.get("armSkuName", "")
                series_match = _PG_PRODUCT_SERIES_RE.search(product)
                series_name = series_match["series"] if series_match else ""
                edition_name = next(
                    (
                        edition
                        for edition, tokens in _PG_EDITION_PRODUCT_TOKENS.items()
                        if any(token in product_l for token in tokens)
                    ),
                    "MemoryOptimized"
                    if series_name.startswith(("E", "M"))
                    else "GeneralPurpose",
                )
                if arm.startswith("Standard_") or arm.upper() in _PG_FLAT_COMPUTE_SKUS:
                    match = _PG_DATABASE_NAME_RE.match(arm)
                    if match is None:
                        continue
                    database_id = (
                        f"Standard_{match['family'].upper()}"
                        f"{match['vcpus']}{match['features'].lower()}"
                    )
                    if match["version"]:
                        database_id += f"_v{match['version']}"
                    retail_concrete.setdefault(database_id, edition_name)
                # Series meters (no Standard_* size) are ignored for existence;
                # they still price sizes via _pg_lookup_retail_price.
        vendor.progress_tracker.advance_task()
    vendor.progress_tracker.hide_task()
    _pg_check_capabilities_parsed(
        vendor, capabilities_seen, len(edition_caps), "server editions"
    )

    # Capabilities SKUs (confidential only from ACC regions), plus Retail sizes
    # that fill gaps inside series already offered by capabilities.
    wanted: dict[str, str] = {}
    for database_id, facts in caps_by_id.items():
        profile = (facts.get("security_profile") or "").lower()
        if profile.startswith("confidential") and not (
            caps_locations[database_id] & _PG_CONFIDENTIAL_CAPABILITY_REGIONS
        ):
            continue
        wanted[database_id] = facts["edition"]
    caps_series = {_parse_database_name(database_id)[0] for database_id in wanted}
    for database_id, edition_name in retail_concrete.items():
        series, _family, _vcpus, _version = _parse_database_name(database_id)
        if series not in caps_series:
            continue
        wanted.setdefault(database_id, edition_name)

    rows = []
    for database_id, edition_name in wanted.items():
        own = caps_by_id.get(database_id)
        facts = (
            own
            or edition_caps.get(edition_name)
            or next(iter(edition_caps.values()), None)
        )
        if facts is None:
            continue
        server = servers_by_id.get(database_id)
        series, _family, vcpus, _version = _parse_database_name(database_id)
        ha, ha_strategy, sla = facts["ha"], facts["ha_strategy"], facts["sla"]
        if own:
            edition_name = own["edition"]
            vcpus = own["vcpus"] or vcpus
            memory_amount = own["memory_amount"]
        else:
            if server and server.vcpus:
                vcpus = server.vcpus
            memory_amount = (
                int(server.memory_amount) if server and server.memory_amount else None
            )
            if edition_name == "Burstable" and edition_name not in edition_caps:
                ha, ha_strategy, sla = (
                    [DatabaseHaLevel.NONE],
                    [DatabaseHaStrategy.NONE],
                    99.9,
                )
        spec_parts = []
        if vcpus is not None:
            spec_parts.append(f"{vcpus} vCPU{'s' if vcpus != 1 else ''}")
        if memory_amount is not None:
            spec_parts.append(f"{memory_amount // 1024} GB RAM")
        description = f"PostgreSQL {edition_name}"
        if spec_parts:
            description += f" ({', '.join(spec_parts)})"
        name = database_id.removeprefix("Standard_")
        sku_prefix = _PG_SKU_NAME_PREFIX.get(edition_name)
        rows.append(
            {
                "vendor_id": vendor.vendor_id,
                "database_id": database_id,
                "name": name,
                "api_reference": database_id,
                # https://www.pulumi.com/registry/packages/azure/api-docs/postgresql/flexibleserver/
                "api_reference_object": {
                    "sku_name": (
                        f"{sku_prefix}_{database_id}" if sku_prefix else database_id
                    )
                },
                "display_name": name,
                "description": description,
                "server_id": server.server_id if server else None,
                "engine": DatabaseEngine.POSTGRESQL,
                "wire_protocol": DatabaseWireProtocol.POSTGRESQL,
                "engine_versions": facts["engine_versions"],
                "family": _pg_edition_family(edition_name),
                "series": series,
                # unknown (None) for an edition the capabilities API did not list
                "compatible_storage_ids": (
                    sorted(storage_ids_by_edition[edition_name])
                    if edition_name in storage_ids_by_edition
                    else None
                ),
                "vcpus": vcpus,
                "memory_amount": memory_amount,
                "storage_size": None,
                "storage_extra_autosize": facts["storage_extra_autosize"],
                # https://learn.microsoft.com/en-us/azure/postgresql/backup-restore/concepts-backup-restore
                "scheduled_backups": True,
                "autotuning_advice": facts["autotuning_advice"],
                "autotuning_apply": facts["autotuning_apply"],
                # https://learn.microsoft.com/en-us/azure/postgresql/security/security-overview#data-protection
                "disk_encryption": True,
                # https://learn.microsoft.com/en-us/azure/postgresql/configure-maintain/concepts-major-version-upgrade
                "auto_upgrade_versions": True,
                # https://learn.microsoft.com/en-us/azure/postgresql/parameters/concepts-parameters
                "custom_config": True,
                # https://learn.microsoft.com/en-us/azure/postgresql/extensions/concepts-extensions-considerations
                "custom_extensions": True,
                "storage_extra_min": facts["storage_extra_min"],
                "storage_extra_max": facts["storage_extra_max"],
                "ha": ha,
                "ha_strategy": ha_strategy,
                # https://learn.microsoft.com/en-us/azure/postgresql/network/concepts-networking-public
                # https://learn.microsoft.com/en-us/azure/postgresql/network/concepts-networking-private
                # https://learn.microsoft.com/en-us/azure/postgresql/network/concepts-networking-private-link
                # https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-configure-sign-in-azure-ad-authentication
                # https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-connect-tls-ssl
                # https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-data-encryption
                # https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-audit
                "security_features": [
                    DatabaseSecurityFeature.IP_FILTERING,
                    DatabaseSecurityFeature.PRIVATE_NETWORK,
                    DatabaseSecurityFeature.NETWORK_PEERING,
                    DatabaseSecurityFeature.IDENTITY_BASED_AUTH,
                    DatabaseSecurityFeature.ENFORCED_TLS,
                    DatabaseSecurityFeature.CUSTOMER_MANAGED_KEYS,
                    DatabaseSecurityFeature.AUDIT_LOGGING,
                ],
                # https://learn.microsoft.com/en-us/azure/postgresql/read-replica/concepts-read-replicas
                "max_read_replicas": 0 if edition_name == "Burstable" else 5,
                # https://learn.microsoft.com/en-us/azure/postgresql/connectivity/concepts-pgbouncer
                "connection_pool": True,
                # https://learn.microsoft.com/en-us/azure/postgresql/monitor/concepts-monitoring
                "system_monitoring": True,
                # https://learn.microsoft.com/en-us/azure/postgresql/monitor/concepts-query-performance-insight
                "database_monitoring": True,
                "continuous_backups": 35,
                "sla": sla,
                # VM size retirements (e.g. B-series v1) are not announced for
                # Flexible Server compute, so don't inherit the VM lifecycle.
                "status": Status.ACTIVE,
            }
        )
    return rows

inventory_database_prices #

inventory_database_prices(vendor)

List Azure Database for PostgreSQL Flexible Server on-demand prices from the Retail Pricing API.

SKU catalog comes from vendor.databases (built by inventory_databases / capabilities). Per-region capabilities are not used for pricing: emit a row whenever Retail has a meter for a known instance in that region.

OfferRestricted=Enabled means this subscription cannot list or provision Flexible Server SKUs there (empty supportedServerEditions), so capabilities give no confirmed region availability. Retail list prices may still exist; we keep those rows. https://learn.microsoft.com/en-us/azure/postgresql/troubleshoot/how-to-resolve-capacity-errors https://learn.microsoft.com/en-us/rest/api/postgresql/capabilities-by-location/list

More information: https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices.

Source code in sc_crawler/vendors/_azure.py
def inventory_database_prices(vendor):
    """List Azure Database for PostgreSQL Flexible Server on-demand prices from the Retail Pricing API.

    SKU catalog comes from ``vendor.databases`` (built by ``inventory_databases`` /
    capabilities). Per-region capabilities are not used for pricing: emit a row
    whenever Retail has a meter for a known instance in that region.

    OfferRestricted=Enabled means this subscription cannot list or provision
    Flexible Server SKUs there (empty supportedServerEditions), so capabilities
    give no confirmed region availability. Retail list prices may still exist;
    we keep those rows.
    https://learn.microsoft.com/en-us/azure/postgresql/troubleshoot/how-to-resolve-capacity-errors
    https://learn.microsoft.com/en-us/rest/api/postgresql/capabilities-by-location/list

    More information: <https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices>.
    """
    items = []
    seen = set()
    regions = _pg_database_regions(vendor)
    vendor.progress_tracker.start_task(
        name="Scanning region(s) for database_price(s)", total=len(regions)
    )
    for region in regions:
        with sentry_capture_or_raise(vendor=vendor):
            prices_by_arm: dict[str, list[dict]] = defaultdict(list)
            for item in _pg_retail_prices(region.api_reference):
                arm = item.get("armSkuName", "")
                if arm and (
                    "compute" in item.get("productName", "").lower()
                    or arm.startswith("Standard_")
                    or arm.upper() in _PG_FLAT_COMPUTE_SKUS
                    or item.get("meterName", "").upper() in _PG_FLAT_COMPUTE_SKUS
                ):
                    prices_by_arm[arm].append(item)

            for database in vendor.databases:
                if not database.status.is_orderable:
                    continue
                price_item = _pg_lookup_retail_price(
                    vendor=vendor,
                    database_id=database.database_id,
                    # series of the database, e.g. Dsv3 to match the product names
                    edition_name=_parse_database_name(database.database_id)[0],
                    prices_by_arm=prices_by_arm,
                )
                if price_item is None:
                    continue
                base_price = _pg_hourly_compute_price(
                    price_item, database.vcpus, database_id=database.database_id
                )
                # https://azure.microsoft.com/pricing/details/postgresql/flexible-server/
                # HA bills primary + standby at the same rate (exactly 2x); SameZone
                # and ZoneRedundant cost the same. No separate retail HA meters.
                ha_levels = {DatabaseHaLevel(level) for level in database.ha or []}
                price_rows = [
                    (DatabaseHaLevel.NONE, DatabaseHaStrategy.NONE, base_price)
                ] + [
                    (level, DatabaseHaStrategy.PASSIVE_STANDBY, base_price * 2)
                    for level in (
                        DatabaseHaLevel.MULTI_ZONE,
                        DatabaseHaLevel.SINGLE_ZONE,
                    )
                    if level in ha_levels
                ]
                for ha, ha_strategy, price in price_rows:
                    key = (region.region_id, database.database_id, ha, ha_strategy)
                    if key in seen:
                        continue
                    seen.add(key)
                    items.append(
                        {
                            "vendor_id": vendor.vendor_id,
                            "region_id": region.region_id,
                            "database_id": database.database_id,
                            "allocation": Allocation.ONDEMAND,
                            "ha": ha,
                            "ha_strategy": ha_strategy,
                            "unit": PriceUnit.HOUR,
                            "price": price,
                            "price_upfront": 0,
                            "price_tiered": [],
                            "currency": price_item.get("currencyCode", "USD"),
                        }
                    )
        vendor.progress_tracker.advance_task()
    vendor.progress_tracker.hide_task()
    return items

inventory_database_storages #

inventory_database_storages(vendor)

List all Azure Database for PostgreSQL Flexible Server storage options via the capabilities API.

Source code in sc_crawler/vendors/_azure.py
def inventory_database_storages(vendor):
    """List all Azure Database for PostgreSQL Flexible Server storage options via the capabilities API."""
    storages: dict[str, dict] = {}
    capabilities_seen = 0
    regions = _pg_database_regions(vendor)
    vendor.progress_tracker.start_task(
        name="Scanning region(s) for database_storage(s)", total=len(regions)
    )
    for region in regions:
        location = region.api_reference
        with sentry_capture_or_raise(vendor=vendor):
            for capability in _pg_capabilities(location):
                capabilities_seen += 1
                for edition in (
                    getattr(capability, "supportedServerEditions", None) or []
                ):
                    for storage_edition in (
                        getattr(edition, "supportedStorageEditions", None) or []
                    ):
                        if (
                            getattr(storage_edition, "reason", None)
                            == _PG_UNSUPPORTED_STORAGE_REASON
                        ):
                            continue
                        storage_id = storage_edition.name
                        if not storage_id:
                            continue

                        sizes_mb: list[int] = []
                        max_iops_values: list[int] = []
                        max_throughput = None
                        default_mb = getattr(
                            storage_edition, "defaultStorageSizeMb", None
                        )
                        if default_mb is not None:
                            sizes_mb.append(int(default_mb))
                        for storage_mb in storage_edition.supportedStorageMb or []:
                            size = getattr(storage_mb, "storageSizeMb", None)
                            if size is not None:
                                sizes_mb.append(int(size))
                            maximum_size = getattr(
                                storage_mb, "maximumStorageSizeMb", None
                            )
                            if maximum_size is not None:
                                sizes_mb.append(int(maximum_size))
                            iops = getattr(storage_mb, "supportedIops", None)
                            if iops is not None:
                                max_iops_values.append(int(iops))
                            maximum_iops = getattr(
                                storage_mb, "supportedMaximumIops", None
                            )
                            if maximum_iops is not None:
                                max_iops_values.append(int(maximum_iops))
                            for tier in (
                                getattr(storage_mb, "supportedIopsTiers", None) or []
                            ):
                                tier_iops = getattr(tier, "iops", None)
                                if tier_iops is not None:
                                    max_iops_values.append(int(tier_iops))
                            throughput = getattr(
                                storage_mb, "supportedMaximumThroughput", None
                            )
                            if throughput is not None:
                                max_throughput = max(
                                    max_throughput or 0, int(throughput)
                                )

                        bounds = {
                            # Azure storageSizeMb values are MiB
                            "min_size": (
                                round(min(sizes_mb) / 1024 * _GIB_TO_GB)
                                if sizes_mb
                                else None
                            ),
                            "max_size": (
                                round(max(sizes_mb) / 1024 * _GIB_TO_GB)
                                if sizes_mb
                                else None
                            ),
                            "max_iops": (
                                max(max_iops_values) if max_iops_values else None
                            ),
                            "max_throughput": max_throughput,
                        }
                        merged = storages.setdefault(
                            storage_id,
                            {
                                "min_size": None,
                                "max_size": None,
                                "max_iops": None,
                                "max_throughput": None,
                            },
                        )
                        for key in (
                            "min_size",
                            "max_size",
                            "max_iops",
                            "max_throughput",
                        ):
                            left, right = merged.get(key), bounds.get(key)
                            if left is None:
                                merged[key] = right
                            elif right is not None:
                                merged[key] = (
                                    min(left, right)
                                    if key == "min_size"
                                    else max(left, right)
                                )
        vendor.progress_tracker.advance_task()
    vendor.progress_tracker.hide_task()
    _pg_check_capabilities_parsed(
        vendor, capabilities_seen, len(storages), "storage editions"
    )

    items = []
    for storage_id, bounds in sorted(storages.items()):
        description_parts = [_PG_STORAGE_DESCRIPTIONS.get(storage_id, storage_id)]
        min_size = bounds.get("min_size")
        max_size = bounds.get("max_size")
        if min_size is not None and max_size is not None:
            description_parts.append(f"{min_size}-{max_size} GB")
        elif min_size is not None:
            description_parts.append(f"from {min_size} GB")
        elif max_size is not None:
            description_parts.append(f"up to {max_size} GB")
        if bounds.get("max_iops") is not None:
            description_parts.append(f"up to {bounds['max_iops']} IOPS")
        if bounds.get("max_throughput") is not None:
            description_parts.append(
                f"up to {bounds['max_throughput']} MB/s throughput"
            )
        items.append(
            {
                "vendor_id": vendor.vendor_id,
                "database_storage_id": storage_id,
                "name": storage_id,
                "description": ", ".join(description_parts),
                "scope": DatabaseStorageScope.DATA,
                "min_size": bounds.get("min_size"),
                "max_size": bounds.get("max_size"),
                "max_iops": bounds.get("max_iops"),
                "max_throughput": bounds.get("max_throughput"),
            }
        )

    items.append(
        {
            "vendor_id": vendor.vendor_id,
            "database_storage_id": _PG_BACKUP_STORAGE_ID,
            "name": _PG_BACKUP_STORAGE_ID,
            "description": "Flexible Server backup storage (locally redundant)",
            # Backup SKU not in capabilities API; id matches retail Backup Storage LRS meter.
            # https://learn.microsoft.com/en-us/azure/postgresql/backup-restore/concepts-backup-restore
            "scope": DatabaseStorageScope.BACKUP,
            "redundancy": "LRS",
        }
    )
    return items

inventory_database_storage_prices #

inventory_database_storage_prices(vendor)

Look up Azure Database for PostgreSQL Flexible Server storage prices via the Azure Retail Prices API.

For more information, see https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices.

Source code in sc_crawler/vendors/_azure.py
def inventory_database_storage_prices(vendor):
    """Look up Azure Database for PostgreSQL Flexible Server storage prices via the Azure Retail Prices API.

    For more information, see <https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices>.
    """
    items = []
    regions = _pg_database_regions(vendor)
    vendor.progress_tracker.start_task(
        name="Scanning region(s) for database_storage_price(s)",
        total=len(regions),
    )
    for region in regions:
        location = region.api_reference
        with sentry_capture_or_raise(vendor=vendor):
            supported_storage_ids = _pg_supported_storage_ids(location)
            for item in _pg_retail_prices(location):
                product = (item.get("productName") or "").lower()
                meter = (item.get("meterName") or "").lower()
                storage_id = (
                    _PG_STORAGE_RETAIL_TO_ID.get(meter)
                    if product in _PG_STORAGE_RETAIL_PRODUCTS
                    else None
                )
                if not storage_id:
                    continue
                if (
                    storage_id != _PG_BACKUP_STORAGE_ID
                    and storage_id not in supported_storage_ids
                ):
                    continue
                multiplier = STORAGE_PRICE_UNIT_MAPPING.get(item.get("unitOfMeasure"))
                if multiplier is None:
                    continue
                items.append(
                    {
                        "vendor_id": vendor.vendor_id,
                        "region_id": region.region_id,
                        "database_storage_id": storage_id,
                        "unit": PriceUnit.GB_MONTH,
                        "price": float(item["retailPrice"]) * multiplier,
                        "price_upfront": 0,
                        "price_tiered": [],
                        "currency": item.get("currencyCode", "USD"),
                    }
                )
        vendor.progress_tracker.advance_task()
    vendor.progress_tracker.hide_task()
    return items