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_METER_MAPPING

Map Storage price meter names to the storage type ID and the disk size in GiB.

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_METER_MAPPING module-attribute #

STORAGE_METER_MAPPING = {'P1 LRS Disk': ('Premium_LRS', 4), 'P2 LRS Disk': ('Premium_LRS', 8), 'P3 LRS Disk': ('Premium_LRS', 16), 'P4 LRS Disk': ('Premium_LRS', 32), 'P6 LRS Disk': ('Premium_LRS', 64), 'P10 LRS Disk': ('Premium_LRS', 128), 'P15 LRS Disk': ('Premium_LRS', 256), 'P20 LRS Disk': ('Premium_LRS', 512), 'P30 LRS Disk': ('Premium_LRS', 1024), 'P40 LRS Disk': ('Premium_LRS', 2048), 'P50 LRS Disk': ('Premium_LRS', 4096), 'P60 LRS Disk': ('Premium_LRS', 8192), 'P70 LRS Disk': ('Premium_LRS', 16384), 'P80 LRS Disk': ('Premium_LRS', 32767), 'P1 ZRS Disk': ('Premium_ZRS', 4), 'P2 ZRS Disk': ('Premium_ZRS', 8), 'P3 ZRS Disk': ('Premium_ZRS', 16), 'P4 ZRS Disk': ('Premium_ZRS', 32), 'P6 ZRS Disk': ('Premium_ZRS', 64), 'P10 ZRS Disk': ('Premium_ZRS', 128), 'P15 ZRS Disk': ('Premium_ZRS', 256), 'P20 ZRS Disk': ('Premium_ZRS', 512), 'P30 ZRS Disk': ('Premium_ZRS', 1024), 'P40 ZRS Disk': ('Premium_ZRS', 2048), 'P50 ZRS Disk': ('Premium_ZRS', 4096), 'P60 ZRS Disk': ('Premium_ZRS', 8192), 'P70 ZRS Disk': ('Premium_ZRS', 16384), 'P80 ZRS Disk': ('Premium_ZRS', 32767), 'E1 LRS Disk': ('StandardSSD_LRS', 4), 'E2 LRS Disk': ('StandardSSD_LRS', 8), 'E3 LRS Disk': ('StandardSSD_LRS', 16), 'E4 LRS Disk': ('StandardSSD_LRS', 32), 'E6 LRS Disk': ('StandardSSD_LRS', 64), 'E10 LRS Disk': ('StandardSSD_LRS', 128), 'E15 LRS Disk': ('StandardSSD_LRS', 256), 'E20 LRS Disk': ('StandardSSD_LRS', 512), 'E30 LRS Disk': ('StandardSSD_LRS', 1024), 'E40 LRS Disk': ('StandardSSD_LRS', 2048), 'E50 LRS Disk': ('StandardSSD_LRS', 4096), 'E60 LRS Disk': ('StandardSSD_LRS', 8192), 'E70 LRS Disk': ('StandardSSD_LRS', 16384), 'E80 LRS Disk': ('StandardSSD_LRS', 32767), 'E1 ZRS Disk': ('StandardSSD_ZRS', 4), 'E2 ZRS Disk': ('StandardSSD_ZRS', 8), 'E3 ZRS Disk': ('StandardSSD_ZRS', 16), 'E4 ZRS Disk': ('StandardSSD_ZRS', 32), 'E6 ZRS Disk': ('StandardSSD_ZRS', 64), 'E10 ZRS Disk': ('StandardSSD_ZRS', 128), 'E15 ZRS Disk': ('StandardSSD_ZRS', 256), 'E20 ZRS Disk': ('StandardSSD_ZRS', 512), 'E30 ZRS Disk': ('StandardSSD_ZRS', 1024), 'E40 ZRS Disk': ('StandardSSD_ZRS', 2048), 'E50 ZRS Disk': ('StandardSSD_ZRS', 4096), 'E60 ZRS Disk': ('StandardSSD_ZRS', 8192), 'E70 ZRS Disk': ('StandardSSD_ZRS', 16384), 'E80 ZRS Disk': ('StandardSSD_ZRS', 32767), 'S4 LRS Disk': ('Standard_LRS', 32), 'S6 LRS Disk': ('Standard_LRS', 64), 'S10 LRS Disk': ('Standard_LRS', 128), 'S15 LRS Disk': ('Standard_LRS', 256), 'S20 LRS Disk': ('Standard_LRS', 512), 'S30 LRS Disk': ('Standard_LRS', 1024), 'S40 LRS Disk': ('Standard_LRS', 2048), 'S50 LRS Disk': ('Standard_LRS', 4096), 'S60 LRS Disk': ('Standard_LRS', 8192), 'S70 LRS Disk': ('Standard_LRS', 16384), 'S80 LRS Disk': ('Standard_LRS', 32767), 'Ultra LRS Provisioned Capacity': ('UltraSSD_LRS', 1), 'Premium LRS Provisioned Capacity': ('PremiumV2_LRS', 1)}

Map Storage price meter names to the storage type ID and the disk size in GiB.

Disk sizes sourced from the Azure Managed Disks pricing page: https://azure.microsoft.com/en-us/pricing/details/managed-disks/

Meter names sourced from the Azure Retail Prices API: https://learn.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices

The disk size (second tuple element) is used to convert per-disk (1/Month) prices to $/GiB/month by dividing the retail price by this value. For provisioned-capacity meters (1 GiB/Hour) the divisor is 1 because the price is already expressed per GiB.

The following meter categories are intentionally not included:

  • * Disk Mount — the extra monthly fee charged per VM when a disk is attached to more than one VM simultaneously (Azure Shared Disks feature). This is an access/ attach charge, not a storage-capacity charge.
  • Confidential Compute Encryption * Provisioned Capacity — surcharge for customer-managed key (CMK) encryption on confidential VMs.
  • LRS/ZRS Burst Enablement — monthly fee to permanently enable burst IOPS on Premium SSD disks.
  • * Disk - Free / SAP Special * — zero-price promotional entries.
  • Instant Access Snapshots — snapshot restore-access fee.
  • Standard HDD ZRS is not offered as per-disk pricing (only as per-GiB/month).

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
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
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
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,
        },
        "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: _azure_sku_lifecycle_status checks _AZURE_SKU_LIFECYCLE_RULES — RETIRED if the retirement date has passed, PLANNED_FOR_RETIREMENT if matched but not yet retired, otherwise ACTIVE. Same function is used for database SKUs.

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

    Lifecycle: `_azure_sku_lifecycle_status` checks `_AZURE_SKU_LIFECYCLE_RULES`
    — RETIRED if the retirement date has passed, PLANNED_FOR_RETIREMENT if
    matched but not yet retired, otherwise ACTIVE. Same function is used for
    database SKUs.
    """
    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"])

    prices = defaultdict(list)
    for p in retail_prices:
        mapping = STORAGE_METER_MAPPING.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
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
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
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] = {}
    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 (
                            getattr(edition, "supportedStorageEditions", None) or []
                        )
                        if getattr(storage_edition, "reason", None)
                        != _PG_UNSUPPORTED_STORAGE_REASON
                        and not (
                            edition.name == "Burstable"
                            and storage_edition.name == "ManagedDiskV2"
                        )
                        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
                    ]
                    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": series,
                "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,
                "status": _azure_sku_lifecycle_status(database_id),
            }
        )
    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,
                    edition_name=database.family,
                    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