適用於 Python 的 Azure 資源庫

概觀

使用 Azure Resource Manager 部署、監視和管理群組中的資源。

管理 API

使用管理 API 來透過範本建立資源群組及部署資源。

pip install azure-mgmt-resource
pip install azure-identity

範例

在 Azure 的美國東部區域建立新的資源群組。

from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import ResourceManagementClient
import os

LOCATION = 'eastus'
GROUP_NAME ='sample_resource_group'

sub_id = os.getenv("AZURE_SUBSCRIPTION_ID")
client = ResourceManagementClient(credential=DefaultAzureCredential(), subscription_id=sub_id)
client.resource_groups.create_or_update(GROUP_NAME, {'location': LOCATION})

範例

管理 Azure 資源和資源群組

檢視 Azure Resource Manager 範例的完整清單