Costs - Create Or Update

Create or replace an existing cost.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/costs/{name}?api-version=2018-09-15

URI Parameters

Name In Required Type Description
labName
path True

string

The name of the lab.

name
path True

string

The name of the cost.

resourceGroupName
path True

string

The name of the resource group.

subscriptionId
path True

string

The subscription ID.

api-version
query True

string

Client API version.

Request Body

Name Type Description
location

string

The location of the resource.

properties.createdDate

string

The creation date of the cost.

properties.currencyCode

string

The currency code of the cost.

properties.endDateTime

string

The end time of the cost data.

properties.startDateTime

string

The start time of the cost data.

properties.targetCost

TargetCostProperties

The target cost properties

tags

object

The tags of the resource.

Responses

Name Type Description
200 OK

LabCost

OK

201 Created

LabCost

Created

Other Status Codes

CloudError

BadRequest

Security

azure_auth

OAuth2 Implicit Grant

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation Access Microsoft Azure

Examples

Costs_CreateOrUpdate

Sample Request

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/costs/targetCost?api-version=2018-09-15

{
  "properties": {
    "currencyCode": "USD",
    "startDateTime": "2020-12-01T00:00:00Z",
    "endDateTime": "2020-12-31T23:59:59Z",
    "targetCost": {
      "costThresholds": [
        {
          "thresholdId": "00000000-0000-0000-0000-000000000001",
          "displayOnChart": "Disabled",
          "sendNotificationWhenExceeded": "Disabled",
          "percentageThreshold": {
            "thresholdValue": 25
          }
        },
        {
          "thresholdId": "00000000-0000-0000-0000-000000000002",
          "displayOnChart": "Enabled",
          "sendNotificationWhenExceeded": "Enabled",
          "percentageThreshold": {
            "thresholdValue": 50
          }
        },
        {
          "thresholdId": "00000000-0000-0000-0000-000000000003",
          "displayOnChart": "Disabled",
          "sendNotificationWhenExceeded": "Disabled",
          "percentageThreshold": {
            "thresholdValue": 75
          }
        },
        {
          "thresholdId": "00000000-0000-0000-0000-000000000004",
          "displayOnChart": "Disabled",
          "sendNotificationWhenExceeded": "Disabled",
          "percentageThreshold": {
            "thresholdValue": 100
          }
        },
        {
          "thresholdId": "00000000-0000-0000-0000-000000000005",
          "displayOnChart": "Disabled",
          "sendNotificationWhenExceeded": "Disabled",
          "percentageThreshold": {
            "thresholdValue": 125
          }
        }
      ],
      "target": 100,
      "cycleStartDateTime": "2020-12-01T00:00:00.000Z",
      "cycleEndDateTime": "2020-12-31T00:00:00.000Z",
      "cycleType": "CalendarMonth",
      "status": "Enabled"
    }
  }
}

Sample Response

{
  "properties": {
    "targetCost": {
      "costThresholds": [
        {
          "thresholdId": "00000000-0000-0000-0000-000000000001",
          "percentageThreshold": {
            "thresholdValue": 25
          },
          "displayOnChart": "Disabled",
          "sendNotificationWhenExceeded": "Disabled",
          "notificationSent": "0001-01-01T00:00:00.0000000"
        },
        {
          "thresholdId": "00000000-0000-0000-0000-000000000001",
          "percentageThreshold": {
            "thresholdValue": 50
          },
          "displayOnChart": "Enabled",
          "sendNotificationWhenExceeded": "Enabled",
          "notificationSent": "0001-01-01T00:00:00.0000000"
        },
        {
          "thresholdId": "00000000-0000-0000-0000-000000000001",
          "percentageThreshold": {
            "thresholdValue": 75
          },
          "displayOnChart": "Disabled",
          "sendNotificationWhenExceeded": "Disabled",
          "notificationSent": "0001-01-01T00:00:00.0000000"
        },
        {
          "thresholdId": "00000000-0000-0000-0000-000000000001",
          "percentageThreshold": {
            "thresholdValue": 100
          },
          "displayOnChart": "Disabled",
          "sendNotificationWhenExceeded": "Disabled",
          "notificationSent": "0001-01-01T00:00:00.0000000"
        },
        {
          "thresholdId": "00000000-0000-0000-0000-000000000001",
          "percentageThreshold": {
            "thresholdValue": 125
          },
          "displayOnChart": "Disabled",
          "sendNotificationWhenExceeded": "Disabled",
          "notificationSent": "0001-01-01T00:00:00.0000000"
        }
      ],
      "status": "Enabled",
      "target": 100,
      "cycleStartDateTime": "2020-12-01T00:00:00+00:00",
      "cycleEndDateTime": "2020-12-31T23:59:59+00:00",
      "cycleType": "CalendarMonth"
    },
    "currencyCode": "USD",
    "startDateTime": "2020-12-01T00:00:00Z",
    "endDateTime": "2020-12-31T23:59:59Z",
    "createdDate": "2020-12-23T22:43:54.7253204+00:00",
    "provisioningState": "Succeeded",
    "uniqueIdentifier": "{uniqueIdentifier}"
  },
  "id": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.devtestlab/labs/{labName}/costs/{costName}",
  "name": "{costName}",
  "type": "Microsoft.DevTestLab/labs/costs",
  "location": "{location}",
  "tags": {
    "tagName1": "tagValue1"
  }
}
{
  "properties": {
    "targetCost": {
      "costThresholds": [
        {
          "thresholdId": "00000000-0000-0000-0000-000000000001",
          "percentageThreshold": {
            "thresholdValue": 25
          },
          "displayOnChart": "Disabled",
          "sendNotificationWhenExceeded": "Disabled",
          "notificationSent": "0001-01-01T00:00:00.0000000"
        },
        {
          "thresholdId": "00000000-0000-0000-0000-000000000001",
          "percentageThreshold": {
            "thresholdValue": 50
          },
          "displayOnChart": "Enabled",
          "sendNotificationWhenExceeded": "Enabled",
          "notificationSent": "0001-01-01T00:00:00.0000000"
        },
        {
          "thresholdId": "00000000-0000-0000-0000-000000000001",
          "percentageThreshold": {
            "thresholdValue": 75
          },
          "displayOnChart": "Disabled",
          "sendNotificationWhenExceeded": "Disabled",
          "notificationSent": "0001-01-01T00:00:00.0000000"
        },
        {
          "thresholdId": "00000000-0000-0000-0000-000000000001",
          "percentageThreshold": {
            "thresholdValue": 100
          },
          "displayOnChart": "Disabled",
          "sendNotificationWhenExceeded": "Disabled",
          "notificationSent": "0001-01-01T00:00:00.0000000"
        },
        {
          "thresholdId": "00000000-0000-0000-0000-000000000001",
          "percentageThreshold": {
            "thresholdValue": 125
          },
          "displayOnChart": "Disabled",
          "sendNotificationWhenExceeded": "Disabled",
          "notificationSent": "0001-01-01T00:00:00.0000000"
        }
      ],
      "status": "Enabled",
      "target": 100,
      "cycleStartDateTime": "2020-12-01T00:00:00+00:00",
      "cycleEndDateTime": "2020-12-31T23:59:59+00:00",
      "cycleType": "CalendarMonth"
    },
    "currencyCode": "USD",
    "startDateTime": "2020-12-01T00:00:00Z",
    "endDateTime": "2020-12-31T23:59:59Z",
    "createdDate": "2020-12-23T22:43:54.7253204+00:00",
    "provisioningState": "Creating",
    "uniqueIdentifier": "{uniqueIdentifier}"
  },
  "id": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.devtestlab/labs/{labName}/costs/{costName}",
  "name": "{costName}",
  "type": "Microsoft.DevTestLab/labs/costs",
  "location": "{location}",
  "tags": {
    "tagName1": "tagValue1"
  }
}

Definitions

Name Description
CloudError

Error from a REST request.

CloudErrorBody

Body of an error from a REST request.

CostThresholdProperties

Properties of a cost threshold item.

CostThresholdStatus

Indicates whether this threshold will be displayed on cost charts.

CostType

The type of the cost.

LabCost

A cost item.

LabCostDetailsProperties

The properties of a lab cost item.

LabCostSummaryProperties

The properties of the cost summary.

LabResourceCostProperties

The properties of a resource cost item.

PercentageCostThresholdProperties

Properties of a percentage cost threshold.

ReportingCycleType

Reporting cycle type.

TargetCostProperties

Properties of a cost target.

TargetCostStatus

Target cost status

CloudError

Error from a REST request.

Name Type Description
error

CloudErrorBody

The cloud error that occurred

CloudErrorBody

Body of an error from a REST request.

Name Type Description
code

string

The error code.

details

CloudErrorBody[]

Inner errors.

message

string

The error message.

target

string

The error target.

CostThresholdProperties

Properties of a cost threshold item.

Name Type Description
displayOnChart

CostThresholdStatus

Indicates whether this threshold will be displayed on cost charts.

notificationSent

string

Indicates the datetime when notifications were last sent for this threshold.

percentageThreshold

PercentageCostThresholdProperties

The value of the percentage cost threshold.

sendNotificationWhenExceeded

CostThresholdStatus

Indicates whether notifications will be sent when this threshold is exceeded.

thresholdId

string

The ID of the cost threshold item.

CostThresholdStatus

Indicates whether this threshold will be displayed on cost charts.

Name Type Description
Disabled

string

Enabled

string

CostType

The type of the cost.

Name Type Description
Projected

string

Reported

string

Unavailable

string

LabCost

A cost item.

Name Type Description
id

string

The identifier of the resource.

location

string

The location of the resource.

name

string

The name of the resource.

properties.createdDate

string

The creation date of the cost.

properties.currencyCode

string

The currency code of the cost.

properties.endDateTime

string

The end time of the cost data.

properties.labCostDetails

LabCostDetailsProperties[]

The lab cost details component of the cost data.

properties.labCostSummary

LabCostSummaryProperties

The lab cost summary component of the cost data.

properties.provisioningState

string

The provisioning status of the resource.

properties.resourceCosts

LabResourceCostProperties[]

The resource cost component of the cost data.

properties.startDateTime

string

The start time of the cost data.

properties.targetCost

TargetCostProperties

The target cost properties

properties.uniqueIdentifier

string

The unique immutable identifier of a resource (Guid).

tags

object

The tags of the resource.

type

string

The type of the resource.

LabCostDetailsProperties

The properties of a lab cost item.

Name Type Description
cost

number

The cost component of the cost item.

costType

CostType

The type of the cost.

date

string

The date of the cost item.

LabCostSummaryProperties

The properties of the cost summary.

Name Type Description
estimatedLabCost

number

The cost component of the cost item.

LabResourceCostProperties

The properties of a resource cost item.

Name Type Description
externalResourceId

string

The ID of the external resource

resourceCost

number

The cost component of the resource cost item.

resourceId

string

The ID of the resource

resourceOwner

string

The owner of the resource (ex. janedoe@microsoft.com)

resourcePricingTier

string

The category of the resource (ex. Premium_LRS, Standard_DS1)

resourceStatus

string

The status of the resource (ex. Active)

resourceType

string

The logical resource type (ex. virtualmachine, storageaccount)

resourceUId

string

The unique identifier of the resource.

resourcename

string

The name of the resource.

PercentageCostThresholdProperties

Properties of a percentage cost threshold.

Name Type Description
thresholdValue

number

The cost threshold value.

ReportingCycleType

Reporting cycle type.

Name Type Description
CalendarMonth

string

Custom

string

TargetCostProperties

Properties of a cost target.

Name Type Description
costThresholds

CostThresholdProperties[]

Cost thresholds.

cycleEndDateTime

string

Reporting cycle end date.

cycleStartDateTime

string

Reporting cycle start date.

cycleType

ReportingCycleType

Reporting cycle type.

status

TargetCostStatus

Target cost status

target

integer

Lab target cost

TargetCostStatus

Target cost status

Name Type Description
Disabled

string

Enabled

string