使用舊版 API 以程式設計方式建立 Azure 訂用帳戶

本文可協助您使用我們舊版的預覽 API,以程式設計方式建立 Azure 訂用帳戶。 在本文中,可了解如何使用 Azure Resource Manager 以程式設計方式建立訂用帳戶。

我們提供了新文章,說明可與不同的 Azure 合約訂用帳戶類型搭配使用的最新 API 版本:

不過,如果您不想要使用最新的 API 版本,仍然可以使用本文中的資訊。

Azure 客戶若使用下列合約類型的計費帳戶,則可以程式設計方式建立訂用帳戶:

  • Enterprise Agreement
  • Microsoft 客戶合約 (MCA)
  • Microsoft 合作夥伴合約 (MPA)

當您以程式設計方式建立 Azure 訂用帳戶時,該訂用帳戶會受協議規範,此協議是您據以向 Microsoft 或授權經銷商取得 Azure 服務的協議。 如需詳細資訊,請參閱 Microsoft Azure 法律資訊。

注意

建議您使用 Azure Az PowerShell 模組來與 Azure 互動。 若要開始使用,請參閱 安裝 Azure PowerShell。 若要瞭解如何移轉至 Az PowerShell 模組,請參閱 將 Azure PowerShell 從 AzureRM 遷移至 Az。

您無法透過程式設計建立支援計劃。 您可以在 Azure 入口網站中購買新的支援計劃,或升級現有的支援計劃。 瀏覽至 說明 + 支援,然後在頁面頂端選取 選擇正確的支援計劃。

為 EA 計費帳戶建立訂用帳戶

使用下列各節中的資訊來建立 EA 訂用帳戶。

必要條件

您必須擁有註冊帳戶的擁有者角色,或必須是企業系統管理員,才能建立訂用帳戶。 有兩種方式可取得此角色:

尋找您可以存取的帳戶

當您加入與「帳戶擁有者」相關聯的註冊帳戶之後,Azure 會使用帳戶與註冊的關聯性來判斷應將訂用帳戶費用計入何處。 所有在該帳戶下所建立訂用帳戶的費用,都會由該帳戶所在的 EA 註冊支付。 若要建立訂用帳戶,您必須傳入註冊帳戶與將擁有該訂用帳戶的使用者主體相關值。

若要執行下列命令,您必須登入帳戶擁有者 的主目錄,這是訂用帳戶預設建立所在的目錄。

要求列出您有權存取的所有註冊帳戶:

GET https://management.azure.com/providers/Microsoft.Billing/enrollmentAccounts?api-version=2018-03-01-preview

API 回應會列出您有權存取的所有註冊帳戶:

{
  "value": [
    {
      "id": "/providers/Microsoft.Billing/enrollmentAccounts/aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb",
      "name": "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb",
      "type": "Microsoft.Billing/enrollmentAccounts",
      "properties": {
        "principalName": "SignUpEngineering@contoso.com"
      }
    },
    {
      "id": "/providers/Microsoft.Billing/enrollmentAccounts/4cd2fcf6-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "name": "4cd2fcf6-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "type": "Microsoft.Billing/enrollmentAccounts",
      "properties": {
        "principalName": "BillingPlatformTeam@contoso.com"
      }
    }
  ]
}

使用 principalName 屬性來識別要將訂用帳戶費用計入的帳戶。 複製該帳戶的 name。 例如,在 SignUpEngineering@contoso.com 註冊帳戶下建立訂用帳戶,複製 aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e。 此識別碼是註冊帳戶的物件識別碼。 將值貼到某處,以便您在下一個步驟中將其作為enrollmentAccountObjectId使用。

在特定的註冊帳戶下建立訂用帳戶

下列範例會在上一個步驟中選取的註冊帳戶中,建立名為 開發小組訂用帳戶 的訂用帳戶。 訂用帳戶供應項目是 MS-AZR-0017P (一般 Microsoft Enterprise 合約)。 這也會依選擇新增兩個使用者作為該訂用帳戶的「Azure RBAC 擁有者」。

提出下列要求,並將<enrollmentAccountObjectId>替換成在第一個步驟 (aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb) 中複製的name。 若要指定擁有者,請參閱 如何取得用戶對象識別碼。

POST https://management.azure.com/providers/Microsoft.Billing/enrollmentAccounts/<enrollmentAccountObjectId>/providers/Microsoft.Subscription/createSubscription?api-version=2018-03-01-preview

{
  "displayName": "Dev Team Subscription",
  "offerType": "MS-AZR-0017P",
  "owners": [
    {
      "objectId": "<userObjectId>"
    },
    {
      "objectId": "<servicePrincipalObjectId>"
    }
  ]
}
元素名稱 必填 類型 描述
displayName 否 繩子 訂用帳戶的顯示名稱。 如果未指定,會設定為供應項目的名稱,例如「Microsoft Azure 企業版」。
offerType 是的 繩子 訂用帳戶的供應項目。 EA 的兩個選項是 MS-AZR-0017P (生產使用)和 MS-AZR-0148P (開發/測試,必須在 Azure 入口網站中啟用)。
owners 否 繩子 在建立訂閱時,任何要在該訂閱上新增為「Azure RBAC 擁有者」之使用者的物件識別碼。

在回應中,您可以從 Location 標頭中取得可查詢訂用帳戶建立作業狀態的 URL。 建立好訂用帳戶之後,Location URL 上的 GET 會傳回 subscriptionLink 物件,其中包含訂用帳戶 ID。 如需詳細資訊,請參閱 訂用帳戶 API 檔

Azure 企業訂用帳戶建立 API 的限制

  • 使用此 API 只能建立「Azure 企業版」訂用帳戶。
  • 每一註冊帳戶只能建立 5000 個訂用帳戶。 之後,您只能在 Azure 入口網站中為帳戶建立更多訂用帳戶。 如果您想要透過 API 建立更多訂用帳戶,請建立另一個註冊帳戶。 已取消、已刪除和已轉移的訂用帳戶會計入 5000 筆上限。
  • 不是「帳戶擁有者」但已透過 Azure RBAC 新增至註冊帳戶的使用者,並無法在 Azure 入口網站中建立訂用帳戶。
  • 您無法選取要在其中建立訂用帳戶的租用戶。 訂用帳戶一律會建立在「帳戶擁有者」的主租用戶中。 若要將訂用帳戶移至不同的租使用者,請參閱 變更訂用帳戶租使用者。

為 MCA 帳戶建立訂用帳戶

使用下列各節中的資訊,建立 MCA 帳戶的訂用帳戶。

必要條件

您必須是發票區段上的擁有者、參與者或 Azure 訂用帳戶建立者角色,或是帳單設定檔或計費帳戶上的擁有者或參與者角色,才能建立訂用帳戶。 如需詳細資訊,請參閱 訂用帳戶計費角色和工作。

下列範例會使用 REST API。 目前不支援 PowerShell 和 Azure CLI。

尋找您可以存取的計費帳戶

請提出下列要求,以列出所有計費帳戶。

GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts?api-version=2019-10-01-preview

API 回應會列出您有權存取的計費帳戶。

{
  "value": [
    {
      "id": "/providers/Microsoft.Billing/billingAccounts/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx",
      "name": "bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx",
      "properties": {
        "accountId": "bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f",
        "accountStatus": "Active",
        "accountType": "Enterprise",
        "agreementType": "MicrosoftCustomerAgreement",
        "displayName": "Contoso",
        "hasReadAccess": true,
        "organizationId": "41b29574-xxxx-xxxx-xxxx-xxxxxxxxxxxxx_xxxx-xx-xx"
      },
      "type": "Microsoft.Billing/billingAccounts"
    },
    {
      "id": "/providers/Microsoft.Billing/billingAccounts/4f89e155-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx",
      "name": "4f89e155-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx",
      "properties": {
        "accountId": "4f89e155-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "accountStatus": "Active",
        "accountType": "Enterprise",
        "agreementType": "MicrosoftCustomerAgreement",
        "displayName": "Fabrikam",
        "hasReadAccess": true,
        "organizationId": "41b29574-xxxx-xxxx-xxxx-xxxxxxxxxxxxx_xxxx-xx-xx"
      },
      "type": "Microsoft.Billing/billingAccounts"
    }
  ]
}

請使用 displayName 屬性來識別您要為其建立訂用帳戶的計費帳戶。 請確定帳戶的 agreementType 是 MicrosoftCustomerAgreement。 複製帳戶的 name。 例如,若要建立 Contoso 計費帳戶的訂用帳戶,請複製 bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx。 將此值貼在某處,以便您在下一個步驟中使用。

尋找發票區段以建立訂用帳戶

訂用帳戶的費用將會顯示在帳單設定檔發票中的某個區段。 請使用下列 API 來取得您有權在其中建立 Azure 訂用帳戶的發票區段和帳單設定檔清單。

提出下列要求,並將<billingAccountName>替換成在第一個步驟 (bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx) 中複製的name。

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/<billingAccountName>/listInvoiceSectionsWithCreateSubscriptionPermission?api-version=2019-10-01-preview

API 回應會列出所有您有權在其中建立訂用帳戶的發票區段及其帳單設定檔:

{
    "value": [{
        "billingProfileDisplayName": "Contoso finance",
        "billingProfileId": "/providers/Microsoft.Billing/billingAccounts/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/PBFV-xxxx-xxx-xxx",
        "enabledAzurePlans": [{
            "productId": "DZH318Z0BPS6",
            "skuId": "0001",
            "skuDescription": "Microsoft Azure Plan"
        }, {
            "productId": "DZH318Z0BPS6",
            "skuId": "0002",
            "skuDescription": "Microsoft Azure Plan for DevTest"
        }],
        "invoiceSectionDisplayName": "Development",
        "invoiceSectionId": "/providers/Microsoft.Billing/billingAccounts/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/PBFV-xxxx-xxx-xxx/invoiceSections/GJ77-xxxx-xxx-xxx"
    }, {
        "billingProfileDisplayName": "Contoso finance",
        "billingProfileId": "/providers/Microsoft.Billing/billingAccounts/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/PBFV-xxxx-xxx-xxx",
        "enabledAzurePlans": [{
            "productId": "DZH318Z0BPS6",
            "skuId": "0001",
            "skuDescription": "Microsoft Azure Plan"
        }, {
            "productId": "DZH318Z0BPS6",
            "skuId": "0002",
            "skuDescription": "Microsoft Azure Plan for DevTest"
        }],
        "invoiceSectionDisplayName": "Testing",
        "invoiceSectionId": "/providers/Microsoft.Billing/billingAccounts/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/PBFV-XXXX-XXX-XXX/invoiceSections/GJGR-XXXX-XXX-XXX"
  }]
}

請使用 invoiceSectionDisplayName 屬性來識別您要為其建立訂閱的發票區段。 複製 invoiceSectionId、billingProfileId 和其中一個 skuId 以用於發票區段。 例如,若要針對 Microsoft Azure plan 發票區段建立 Development 類型的訂用帳戶,請複製 /providers/Microsoft.Billing/billingAccounts/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_2019-05-31/billingProfiles/PBFV-XXXX-XXX-XXX/invoiceSections/GJGR-XXXX-XXX-XXX、/providers/Microsoft.Billing/billingAccounts/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_2019-05-31/billingProfiles/PBFV-xxxx-xxx-xxx 和 0001。 將這些值貼入某處,以便您在下一個步驟中使用。

為發票區段建立訂用帳戶

下列範例會為開發發票區段建立一個名為Dev Team 訂用帳戶、類型為Microsoft Azure 方案的訂用帳戶。 訂用帳戶的費用會計入「Contoso 財務部門」帳單設定檔,並出現在其發票的「開發」區段中。

提出下列要求,並將<invoiceSectionId>替換成在第二個步驟 (/providers/Microsoft.Billing/billingAccounts/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_2019-05-31/billingProfiles/PBFV-XXXX-XXX-XXX/invoiceSections/GJGR-XXXX-XXX-XXX) 中複製的invoiceSectionId。 將您在第二個步驟中複製的 billingProfileId 和 skuId 傳遞至 API 的要求參數。 若要指定擁有者,請參閱 如何取得用戶對象識別碼。

POST https://management.azure.com<invoiceSectionId>/providers/Microsoft.Subscription/createSubscription?api-version=2018-11-01-preview
'{"displayName": "Dev Team subscription",
  "billingProfileId": "<billingProfileId>",
  "skuId": "<skuId>",
  "owners": [
      {
        "objectId": "<userObjectId>"
      },
      {
        "objectId": "<servicePrincipalObjectId>"
      }
    ],
  "costCenter": "35683",
  "managementGroupId": "/providers/Microsoft.Management/managementGroups/xxxxxxx",",
}'

元素名稱 必填 類型 描述
displayName 是的 繩子 訂用帳戶的顯示名稱。
billingProfileId 是的 繩子 要對訂用帳戶收取費用的帳單設定檔識別碼。
skuId 是的 繩子 決定 Azure 方案類型的 SKU 識別碼。
owners 否 繩子 在建立訂用帳戶時,任何要在該訂用帳戶上新增為「Azure RBAC 擁有者」的使用者或服務主體的「物件識別碼」。
costCenter 否 繩子 與訂用帳戶相關聯的成本中心。 這會顯示在使用量 CSV 檔案中。
managementGroupId 否 繩子 其中將新增訂用帳戶的管理群組識別碼。 若要取得管理群組的清單,請參閱 管理群組 - 列表 API。 使用 API 中的管理群組識別碼。

在回應中,會傳回一個 subscriptionCreationResult 物件供您監視。 訂閱建立完成後,subscriptionCreationResult 物件會傳回 subscriptionLink 物件,其中包含訂閱識別碼。

為 MPA 計費帳戶建立訂用帳戶

使用下列各節中的資訊,建立 MPA 計費帳戶的訂用帳戶。

必要條件

您必須在組織的雲端解決方案提供者帳戶中擁有管理員代理人角色,才能為您的計費帳戶建立訂用帳戶。 如需詳細資訊,請參閱 合作夥伴中心 - 指派使用者角色和許可權。

下列範例會使用 REST API。 目前不支援 PowerShell 和 Azure CLI。

尋找您可以存取的計費帳戶

請在下方提出要求,以列出您有權存取的所有計費帳戶。

GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts?api-version=2019-10-01-preview

API 回應會列出計費帳戶。

{
  "value": [
    {
      "id": "/providers/Microsoft.Billing/billingAccounts/cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx",
      "name": "cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx",
      "properties": {
        "accountId": "bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f",
        "accountStatus": "Active",
        "accountType": "Enterprise",
        "agreementType": "MicrosoftPartnerAgreement",
        "displayName": "Contoso",
        "hasReadAccess": true,
        "organizationId": "1d100e69-xxxx-xxxx-xxxx-xxxxxxxxxxxxx_xxxx-xx-xx"
      },
      "type": "Microsoft.Billing/billingAccounts"
    },
    {
      "id": "/providers/Microsoft.Billing/billingAccounts/4f89e155-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx",
      "name": "4f89e155-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx",
      "properties": {
        "accountId": "4f89e155-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "accountStatus": "Active",
        "accountType": "Enterprise",
        "agreementType": "MicrosoftCustomerAgreement",
        "displayName": "Fabrikam",
        "hasReadAccess": true,
        "organizationId": "1d100e69-xxxx-xxxx-xxxx-xxxxxxxxxxxxx_xxxx-xx-xx"
      },
      "type": "Microsoft.Billing/billingAccounts"
    }
  ]
}

請使用 displayName 屬性來識別您要為其建立訂用帳戶的計費帳戶。 請確定帳戶的 agreementType 是 MicrosoftPartnerAgreement。 複製該帳戶的 name。 例如,若要建立 Contoso 計費帳戶的訂用帳戶,請複製 cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx。 將此值貼在某處,以便您在下一個步驟中使用。

尋找具有 Azure 方案的客戶

提出下列要求,並將<billingAccountName>替換成在第一個步驟 (bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx) 中複製的name,以列出計費帳戶中您可以為其建立 Azure 訂用帳戶的所有客戶。

GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/<billingAccountName>/customers?api-version=2019-10-01-preview

API 回應會列出計費帳戶中具有 Azure 方案的客戶。 您可以為客戶建立訂用帳戶。

{
  "value": [
    {
      "id": "/providers/Microsoft.Billing/billingAccounts/cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/dddd3d3d-ee4e-ff5f-aa6a-bbbbbb7b7b7b",
      "name": "dddd3d3d-ee4e-ff5f-aa6a-bbbbbb7b7b7b",
      "properties": {
        "billingProfileDisplayName": "Contoso USD",
        "billingProfileId": "/providers/Microsoft.Billing/billingAccounts/cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/JUT6-xxxx-xxxx-xxxx",
        "displayName": "Fabrikam toys"
      },
      "type": "Microsoft.Billing/billingAccounts/customers"
    },
    {
      "id": "/providers/Microsoft.Billing/billingAccounts/cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/97c3fac4-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "name": "97c3fac4-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "properties": {
        "billingProfileDisplayName": "Fabrikam sports",
        "billingProfileId": "/providers/Microsoft.Billing/billingAccounts/cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/JUT6-xxxx-xxxx-xxxx",
        "displayName": "Fabrikam bakery"
      },
      "type": "Microsoft.Billing/billingAccounts/customers"
    }]
}

請使用 displayName 屬性來識別您要為其建立訂用帳戶的客戶。 為客戶複製id。 例如,若要建立 Fabrikam toys 的訂用帳戶,請複製 /providers/Microsoft.Billing/billingAccounts/cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/dddd3d3d-ee4e-ff5f-aa6a-bbbbbb7b7b7b。 將此值貼到某個位置,以便在後續步驟中使用。

間接提供者的選用服務:取得客戶的經銷商

如果您是 CSP 兩層型模型中的間接提供者,您可以在為客戶建立訂用帳戶時指定轉銷商。

提出下列要求,並將 <customerId> 取代為第二個步驟中複製的 id (/providers/Microsoft.Billing/billingAccounts/cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/dddd3d3d-ee4e-ff5f-aa6a-bbbbbb7b7b7b),以列出客戶適用的所有轉銷商。

GET https://management.azure.com<customerId>?$expand=resellers&api-version=2019-10-01-preview

API 回應會列出客戶適用的轉售商:

{
  "value": [{
  "id": "/providers/Microsoft.Billing/billingAccounts/cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2ed2c490-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "name": "2ed2c490-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "type": "Microsoft.Billing/billingAccounts/customers",
  "properties": {
    "displayName": "Fabrikam toys",
    "resellers": [
      {
        "resellerId": "3xxxxx",
        "description": "Wingtip"
      }
    ]
  }
},
{
  "id": "/providers/Microsoft.Billing/billingAccounts/cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/4ed2c793-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "name": "4ed2c793-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "type": "Microsoft.Billing/billingAccounts/customers",
  "properties": {
    "displayName": "Fabrikam toys",
    "resellers": [
      {
        "resellerId": "5xxxxx",
        "description": "Tailspin"
      }
    ]
  }
}]
}

請使用 description 屬性來識別要與訂用帳戶建立關聯的轉銷商。 為轉銷商複製 resellerId。 例如,若要關聯 Wingtip,請複製 3xxxxx。 將此值貼在某處,以便您在下一個步驟中使用。

為客戶建立訂用帳戶

下列範例會為 Fabrikam 玩具建立一個名為 Dev Team 訂閱的訂閱,並將 Wingtip 轉銷商關聯至該訂閱。

提出下列要求,並將<customerId>替換成在第二個步驟 (/providers/Microsoft.Billing/billingAccounts/cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/dddd3d3d-ee4e-ff5f-aa6a-bbbbbb7b7b7b) 中複製的id。 在 API 請求參數中傳遞從第二步複製的選擇性 resellerId。

POST https://management.azure.com<customerId>/providers/Microsoft.Subscription/createSubscription?api-version=2018-11-01-preview
'{"displayName": "Dev Team subscription",
  "skuId": "0001",
  "resellerId": "<resellerId>",
}'
元素名稱 必填 類型 描述
displayName 是的 繩子 訂用帳戶的顯示名稱。
skuId 是的 繩子 Azure 方案的 SKU 識別碼。 針對 Microsoft Azure 方案類型的訂用帳戶,使用 0001
resellerId 否 繩子 將與訂閱建立關聯的轉銷商識別碼。

在回應中,會傳回一個 subscriptionCreationResult 物件供您監視。 建立完訂閱之後,subscriptionCreationResult 物件會傳回 subscriptionLink 物件。 其中包含訂用帳戶識別碼。

下一步