Cost Allocation Rules - Create Or Update

課金アカウントまたはエンタープライズ登録内の異なるリソース間でコストを割り当てるルールを作成または更新します。

PUT https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/costAllocationRules/{ruleName}?api-version=2023-11-01

URI パラメーター

名前 / 必須 説明
billingAccountId
path True

string

BillingAccount ID

ruleName
path True

string

コスト割り当てルール名。 名前には、スペースまたは '_' と '-' 以外の英数字以外の文字を含めることはできません。 最大長は 260 文字です。

正規表現パターン: [A-Za-z0-9\-_]+

api-version
query True

string

この操作に使用する API バージョン。

要求本文

名前 説明
properties

CostAllocationRuleProperties

コスト配賦ルールのプロパティ

応答

名前 説明
200 OK

CostAllocationRuleDefinition

OK です。 更新要求が成功しました。

201 Created

CostAllocationRuleDefinition

作成されました。 要求は成功しました。

Other Status Codes

ErrorResponse

操作に失敗した理由を説明するエラー応答。

セキュリティ

azure_auth

Azure Active Directory OAuth2 フロー。

型: oauth2
フロー: implicit
Authorization URL (承認 URL): https://login.microsoftonline.com/common/oauth2/authorize

スコープ

名前 説明
user_impersonation ユーザー アカウントの借用

CostAllocationRulesCreateResourceGroup
CostAllocationRulesCreateTag

CostAllocationRulesCreateResourceGroup

要求のサンプル

PUT https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule?api-version=2023-11-01

{
  "properties": {
    "description": "This is a testRule",
    "status": "Active",
    "details": {
      "sourceResources": [
        {
          "resourceType": "Dimension",
          "name": "ResourceGroupName",
          "values": [
            "sampleRG",
            "secondRG"
          ]
        }
      ],
      "targetResources": [
        {
          "resourceType": "Dimension",
          "policyType": "FixedProportion",
          "name": "ResourceGroupName",
          "values": [
            {
              "name": "destinationRG",
              "percentage": 45
            },
            {
              "name": "destinationRG2",
              "percentage": 54
            }
          ]
        }
      ]
    }
  }
}

応答のサンプル

{
  "id": "providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule",
  "name": "testRule",
  "type": "Microsoft.CostManagement/costAllocationRules",
  "properties": {
    "description": "This is a testRule",
    "createdDate": "2020-06-18T22:21:51.1287144Z",
    "updatedDate": "2020-06-18T22:21:51.1287144Z",
    "status": "Creating",
    "details": {
      "sourceResources": [
        {
          "resourceType": "Dimension",
          "name": "ResourceGroupName",
          "values": [
            "sampleRG"
          ]
        }
      ],
      "targetResources": [
        {
          "resourceType": "Dimension",
          "policyType": "FixedProportion",
          "name": "ResourceGroupName",
          "values": [
            {
              "name": "destinationRG",
              "percentage": 50
            },
            {
              "name": "destinationRG2",
              "percentage": 50
            }
          ]
        }
      ]
    }
  }
}
{
  "id": "providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule",
  "name": "testRule",
  "type": "Microsoft.CostManagement/costAllocationRules",
  "properties": {
    "description": "This is a testRule",
    "createdDate": "2020-06-18T22:21:51.1287144Z",
    "updatedDate": "2020-06-18T22:21:51.1287144Z",
    "status": "Creating",
    "details": {
      "sourceResources": [
        {
          "resourceType": "Dimension",
          "name": "ResourceGroupName",
          "values": [
            "sampleRG"
          ]
        }
      ],
      "targetResources": [
        {
          "resourceType": "Dimension",
          "policyType": "FixedProportion",
          "name": "ResourceGroupName",
          "values": [
            {
              "name": "destinationRG",
              "percentage": 50
            },
            {
              "name": "destinationRG2",
              "percentage": 50
            }
          ]
        }
      ]
    }
  }
}

CostAllocationRulesCreateTag

要求のサンプル

PUT https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule?api-version=2023-11-01

{
  "properties": {
    "description": "This is a testRule",
    "status": "Active",
    "details": {
      "sourceResources": [
        {
          "resourceType": "Tag",
          "name": "category",
          "values": [
            "devops"
          ]
        }
      ],
      "targetResources": [
        {
          "resourceType": "Dimension",
          "policyType": "FixedProportion",
          "name": "ResourceGroupName",
          "values": [
            {
              "name": "destinationRG",
              "percentage": 33.33
            },
            {
              "name": "destinationRG2",
              "percentage": 33.33
            },
            {
              "name": "destinationRG3",
              "percentage": 33.34
            }
          ]
        }
      ]
    }
  }
}

応答のサンプル

{
  "id": "providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule",
  "name": "testRule",
  "type": "Microsoft.CostManagement/costAllocationRules",
  "properties": {
    "description": "This is a testRule",
    "createdDate": "2020-06-18T22:21:51.1287144Z",
    "updatedDate": "2020-06-18T22:21:51.1287144Z",
    "status": "Creating",
    "details": {
      "sourceResources": [
        {
          "resourceType": "Dimension",
          "name": "ResourceGroupName",
          "values": [
            "sampleRG"
          ]
        }
      ],
      "targetResources": [
        {
          "resourceType": "Dimension",
          "policyType": "FixedProportion",
          "name": "ResourceGroupName",
          "values": [
            {
              "name": "destinationRG",
              "percentage": 50
            },
            {
              "name": "destinationRG2",
              "percentage": 50
            }
          ]
        }
      ]
    }
  }
}
{
  "id": "providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule",
  "name": "testRule",
  "type": "Microsoft.CostManagement/costAllocationRules",
  "properties": {
    "description": "This is a testRule",
    "createdDate": "2020-06-18T22:21:51.1287144Z",
    "updatedDate": "2020-06-18T22:21:51.1287144Z",
    "status": "Creating",
    "details": {
      "sourceResources": [
        {
          "resourceType": "Dimension",
          "name": "ResourceGroupName",
          "values": [
            "sampleRG"
          ]
        }
      ],
      "targetResources": [
        {
          "resourceType": "Dimension",
          "policyType": "FixedProportion",
          "name": "ResourceGroupName",
          "values": [
            {
              "name": "destinationRG",
              "percentage": 50
            },
            {
              "name": "destinationRG2",
              "percentage": 50
            }
          ]
        }
      ]
    }
  }
}

定義

名前 説明
CostAllocationPolicyType

コストの割り当てに使用する方法。 FixedProportion は、コストが指定されたパーセンテージ値に基づいて分割されることを示します。

CostAllocationProportion

ターゲット リソースと割り当て

CostAllocationResourceType

割り当てに使用するリソースのカテゴリ。

CostAllocationRuleDefinition

コスト配賦規則モデルの定義

CostAllocationRuleDetails

コスト割り当てルールのリソースの詳細

CostAllocationRuleProperties

コスト割り当てルールのプロパティ

ErrorDetails

エラーの詳細。

ErrorResponse

エラー応答は、サービスが受信要求を処理できないことを示します。 理由は、エラー メッセージに表示されます。

いくつかのエラー応答:

  • 429 TooManyRequests - 要求が調整されました。 "x-ms-ratelimit-microsoft.consumption-retry-after" ヘッダーで指定された時間を待ってから再試行します。

  • 503 ServiceUnavailable - サービスは一時的に使用できません。 "Retry-After" ヘッダーで指定された時刻まで待ってから、再試行してください。

RuleStatus

ルールの現在の状態。

SourceCostAllocationResource

コスト割り当てのソース リソース

TargetCostAllocationResource

コスト割り当てのターゲット リソース。

CostAllocationPolicyType

コストの割り当てに使用する方法。 FixedProportion は、コストが指定されたパーセンテージ値に基づいて分割されることを示します。

名前 説明
FixedProportion

string

CostAllocationProportion

ターゲット リソースと割り当て

名前 説明
name

string

コスト割り当てのターゲット リソース

percentage

number

このリソースに割り当てるソース コストの割合。 この値は小数点以下 2 桁に指定でき、このルール内のすべてのリソースの合計パーセンテージは 100.00 に合計する必要があります。

CostAllocationResourceType

割り当てに使用するリソースのカテゴリ。

名前 説明
Dimension

string

サブスクリプション ID やリソース グループ名などの Azure ディメンションが割り当てに使用されていることを示します。

Tag

string

Azure Tag キー値のペアに基づいてコストを割り当てます。

CostAllocationRuleDefinition

コスト配賦規則モデルの定義

名前 説明
id

string

ルールの Azure Resource Manager ID。 これは読み取り ony 値です。

name

string

ルールの名前。 これは読み取り専用の値です。

properties

CostAllocationRuleProperties

コスト配賦ルールのプロパティ

type

string

ルールのリソースの種類。 これは、Microsoft.CostManagement/CostAllocationRule の読み取り専用値です。

CostAllocationRuleDetails

コスト割り当てルールのリソースの詳細

名前 説明
sourceResources

SourceCostAllocationResource[]

コスト割り当てのソース リソース。 現時点では、このリストには複数の要素を含めることができます。

targetResources

TargetCostAllocationResource[]

コスト割り当てのターゲット リソース。 現時点では、このリストには複数の要素を含めることができます。

CostAllocationRuleProperties

コスト割り当てルールのプロパティ

名前 説明
createdDate

string

ルールが作成された時刻。 同じリソースのコストを変更するルールは、作成順に適用されます。

description

string

コスト配分ルールの説明。

details

CostAllocationRuleDetails

コスト配分ルールのリソース情報

status

RuleStatus

ルールの状態

updatedDate

string

ルールが最後に更新された時刻。

ErrorDetails

エラーの詳細。

名前 説明
code

string

エラー コード。

message

string

操作が失敗した理由を示すエラー メッセージ。

ErrorResponse

エラー応答は、サービスが受信要求を処理できないことを示します。 理由は、エラー メッセージに表示されます。

いくつかのエラー応答:

  • 429 TooManyRequests - 要求が調整されました。 "x-ms-ratelimit-microsoft.consumption-retry-after" ヘッダーで指定された時間を待ってから再試行します。

  • 503 ServiceUnavailable - サービスは一時的に使用できません。 "Retry-After" ヘッダーで指定された時刻まで待ってから、再試行してください。

名前 説明
error

ErrorDetails

エラーの詳細。

RuleStatus

ルールの現在の状態。

名前 説明
Active

string

ルールが保存され、コスト割り当てに影響します。

NotActive

string

ルールは保存されますが、コストの割り当てには使用されません。

Processing

string

ルールが保存され、コストの割り当てが更新されています。 put 要求で送信できない読み取り専用の値。

SourceCostAllocationResource

コスト割り当てのソース リソース

名前 説明
name

string

リソースの種類がディメンションの場合、これは ResourceGroupName または SubscriptionId である必要があります。 リソースの種類が tag の場合、これは有効な Azure タグである必要があります

resourceType

CostAllocationResourceType

このコスト割り当てルールに含まれるリソースの種類

values

string[]

コスト割り当てのソース リソース。 このリストには、25 を超える値を含めることはできません。

TargetCostAllocationResource

コスト割り当てのターゲット リソース。

名前 説明
name

string

リソースの種類がディメンションの場合、これは ResourceGroupName または SubscriptionId である必要があります。 リソースの種類が tag の場合、これは有効な Azure タグである必要があります

policyType

CostAllocationPolicyType

ルールのコスト配分方法

resourceType

CostAllocationResourceType

このコスト割り当てルールに含まれるリソースの種類

values

CostAllocationProportion[]

コスト割り当てのターゲット リソース。 このリストには、25 を超える値を含めることはできません。