您可以使用 Azure 計費 API,以程式設計方式提高自己的權權,管理目錄中的所有計費帳戶。
尋找目錄中的所有計費帳戶
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts?includeAllOrgs=true&api-version=2020-05-01
API 回應會傳回目錄中的計費帳戶清單。
{
"value": [
{
"id": "/providers/Microsoft.Billing/billingAccounts/6e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx",
"name": "6e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx",
"properties": {
"accountStatus": "Active",
"accountType": "Individual",
"agreementType": "MicrosoftCustomerAgreement",
"billingProfiles": {
"hasMoreResults": false
},
"displayName": "Connie Wilson",
"hasReadAccess": true
},
"type": "Microsoft.Billing/billingAccounts"
},
{
"id": "/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx",
"name": "5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx",
"properties": {
"accountStatus": "Active",
"accountType": "Enterprise",
"agreementType": "MicrosoftCustomerAgreement",
"billingProfiles": {
"hasMoreResults": false
},
"displayName": "Contoso",
"hasReadAccess": true
},
"type": "Microsoft.Billing/billingAccounts"
},
{
"id": "/providers/Microsoft.Billing/billingAccounts/4e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx",
"name": "4e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx",
"properties": {
"accountStatus": "Active",
"accountType": "Individual",
"agreementType": "MicrosoftCustomerAgreement",
"billingProfiles": {
"hasMoreResults": false
},
"displayName": "Tomas Wilson",
"hasReadAccess": true
},
"type": "Microsoft.Billing/billingAccounts"
}
]
}
使用計費帳戶的 displayName
屬性來識別您要提高存取權的計費帳戶。 複製計費帳戶的 name
。 例如,如果您想要將自己提高為 Connie Wilson 計費帳戶上的擁有者,請複製 6e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx
。 將此值貼在某處,以便您在下一個步驟中使用。
取得計費帳戶可用的角色定義
提出下列要求,並以在第一個步驟複製的 name
取代 <billingAccountName>
(6e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx
)。
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/<billingAccountName>/billingRoleDefinitions?api-version=2020-05-01
API 回應會傳回計費帳戶可用的角色清單。
{
"value": [
{
"id": "/providers/Microsoft.Billing/billingAccounts/6e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx/billingRoleDefinitions/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
"name": "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
"properties": {
"description": "The Owner role gives the user all permissions including access management on a billing account.",
"permissions": [
{
"actions": [
"a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
"a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
"a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
"a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1"
]
}
],
"roleName": "Billing account owner"
},
"type": "Microsoft.Billing/billingAccounts/billingRoleDefinitions"
},
{
"id": "/providers/Microsoft.Billing/billingAccounts/6e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx/billingRoleDefinitions/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
"name": "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
"properties": {
"description": "The Contributor role gives the user all permissions except access management on a billing account.",
"permissions": [
{
"actions": [
"a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
"a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
"a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
]
}
],
"roleName": "Billing account contributor"
},
"type": "Microsoft.Billing/billingAccounts/billingRoleDefinitions"
},
{
"id": "/providers/Microsoft.Billing/billingAccounts/6e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx/billingRoleDefinitions/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
"name": "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
"properties": {
"description": "The Reader role gives the user read permissions to a billing account.",
"permissions": [
{
"actions": [
"a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
"a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
"a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
]
}
],
"roleName": "Billing account reader"
},
"type": "Microsoft.Billing/billingAccounts/billingRoleDefinitions"
}
]
}
使用 roleName
屬性來識別擁有者角色定義。 複製角色定義的 name
。 例如,從上述 API 回應中,您會複製 a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1
。 將此值貼在某處,以便您在下一個步驟中使用。
將自己新增為擁有者
提出下列要求,並以在第一個步驟複製的 name
取代 <billingAccountName>
(6e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxx-xx-xx
)。
PUT https://management.azure.com/providers/Microsoft.Billing/billingAccounts/<billingAccountName>/createBillingRoleAssignment?api-version=2020-05-01
要求本文
若要將自己新增為擁有者,您需要取得物件識別碼。 您可以在 Azure 入口網站 Microsoft Entra ID 區段的 [使用者] 頁面中找到物件識別碼,或者也可以使用 Microsoft Graph API 來取得物件識別碼。
在要求本文中,請將 <roleDefinitionName>
取代為 從步驟 2 複製的 name
。 將 <principalId>
取代為您從 Azure 入口網站或透過 Microsoft Graph API 取得的物件識別碼。
{
"principalId": "<principalId>",
"roleDefinitionId": "<roleDefinitionName>"
}