Views - Create Or Update By Scope

The operation to create or update a view. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.

PUT https://management.azure.com/{scope}/providers/Microsoft.CostManagement/views/{viewName}?api-version=2024-08-01

URI Parameters

Name In Required Type Description
scope
path True

string

The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope.

viewName
path True

string

View name

api-version
query True

string

The API version to use for this operation.

Request Body

Name Required Type Description
properties.query.timeframe True

ReportTimeframeType

The time frame for pulling data for the report. If custom, then a specific time period must be provided.

properties.query.type True

ReportType

The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates.

eTag

string

eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.

properties.accumulated

AccumulatedType

Show costs accumulated over time.

properties.chart

ChartType

Chart type of the main view in Cost Analysis. Required.

properties.dateRange

string

Date range of the current view.

properties.displayName

string

User input name of the view. Required.

properties.kpis

KpiProperties[]

List of KPIs to show in Cost Analysis UI.

properties.metric

MetricType

Metric to use when displaying costs.

properties.modifiedOn

string

Date when the user last modified this view.

properties.pivots

PivotProperties[]

Configuration of 3 sub-views in the Cost Analysis UI.

properties.query.dataSet

ReportConfigDataset

Has definition for data in this report config.

properties.query.includeMonetaryCommitment

boolean

If true, report includes monetary commitment.

properties.query.timePeriod

ReportConfigTimePeriod

Has time period for pulling data for the report.

properties.scope

string

Cost Management scope to save the view on. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription scope.

Responses

Name Type Description
200 OK

View

OK. The request has succeeded.

201 Created

View

Created.

Other Status Codes

ErrorResponse

Error response describing why the operation failed.

Security

azure_auth

Azure Active Directory OAuth2 Flow.

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

Scopes

Name Description
user_impersonation impersonate your user account

Examples

ResourceGroupCreateOrUpdateView

Sample request

PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/views/swaggerExample?api-version=2024-08-01

{
  "eTag": "\"1d4ff9fe66f1d10\"",
  "properties": {
    "displayName": "swagger Example",
    "query": {
      "type": "Usage",
      "timeframe": "MonthToDate",
      "dataSet": {
        "granularity": "Daily",
        "aggregation": {
          "totalCost": {
            "name": "PreTaxCost",
            "function": "Sum"
          }
        },
        "grouping": [],
        "sorting": [
          {
            "direction": "Ascending",
            "name": "UsageDate"
          }
        ]
      }
    },
    "chart": "Table",
    "accumulated": "true",
    "metric": "ActualCost",
    "kpis": [
      {
        "type": "Forecast",
        "id": null,
        "enabled": true
      },
      {
        "type": "Budget",
        "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo",
        "enabled": true
      }
    ],
    "pivots": [
      {
        "type": "Dimension",
        "name": "ServiceName"
      },
      {
        "type": "Dimension",
        "name": "MeterCategory"
      },
      {
        "type": "TagKey",
        "name": "swaggerTagKey"
      }
    ]
  }
}

Sample response

{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/views/swaggerExample",
  "name": "swaggerExample",
  "type": "Microsoft.CostManagement/Views",
  "eTag": "\"1d4ffa5a9c2430c\"",
  "properties": {
    "displayName": "swagger Example",
    "scope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG",
    "query": {
      "type": "Usage",
      "timeframe": "MonthToDate",
      "dataSet": {
        "granularity": "Daily",
        "aggregation": {
          "totalCost": {
            "name": "PreTaxCost",
            "function": "Sum"
          }
        },
        "grouping": [],
        "sorting": [
          {
            "direction": "Ascending",
            "name": "UsageDate"
          }
        ]
      }
    },
    "chart": "Table",
    "accumulated": "true",
    "metric": "ActualCost",
    "kpis": [
      {
        "type": "Forecast",
        "id": null,
        "enabled": true
      },
      {
        "type": "Budget",
        "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo",
        "enabled": true
      }
    ],
    "pivots": [
      {
        "type": "Dimension",
        "name": "ServiceName"
      },
      {
        "type": "Dimension",
        "name": "MeterCategory"
      },
      {
        "type": "TagKey",
        "name": "swaggerTagKey"
      }
    ]
  }
}
{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/views/swaggerExample",
  "name": "swaggerExample",
  "type": "Microsoft.CostManagement/Views",
  "eTag": "\"1d4ffa5a9c2430c\"",
  "properties": {
    "displayName": "swagger Example",
    "scope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG",
    "query": {
      "type": "Usage",
      "timeframe": "MonthToDate",
      "dataSet": {
        "granularity": "Daily",
        "aggregation": {
          "totalCost": {
            "name": "PreTaxCost",
            "function": "Sum"
          }
        },
        "grouping": [],
        "sorting": [
          {
            "direction": "Ascending",
            "name": "UsageDate"
          }
        ]
      }
    },
    "chart": "Table",
    "accumulated": "true",
    "metric": "ActualCost",
    "kpis": [
      {
        "type": "Forecast",
        "id": null,
        "enabled": true
      },
      {
        "type": "Budget",
        "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo",
        "enabled": true
      }
    ],
    "pivots": [
      {
        "type": "Dimension",
        "name": "ServiceName"
      },
      {
        "type": "Dimension",
        "name": "MeterCategory"
      },
      {
        "type": "TagKey",
        "name": "swaggerTagKey"
      }
    ]
  }
}

Definitions

Name Description
AccumulatedType

Show costs accumulated over time.

ChartType

Chart type of the main view in Cost Analysis. Required.

ErrorDetails

The details of the error.

ErrorResponse

Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message.

Some Error responses:

  • 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" header.

  • 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" header.

FunctionType

The name of the aggregation function to use.

KpiProperties

Each KPI must contain a 'type' and 'enabled' key.

KpiTypeType

KPI type (Forecast, Budget).

MetricType

Metric to use when displaying costs.

OperatorType

The operator to use for comparison.

PivotProperties

Each pivot must contain a 'type' and 'name'.

PivotTypeType

Data type to show in view.

QueryColumnType

The type of the column in the export.

ReportConfigAggregation

The aggregation expression to be used in the report.

ReportConfigComparisonExpression

The comparison expression to be used in the report.

ReportConfigDataset

The definition of data present in the report.

ReportConfigDatasetConfiguration

The configuration of dataset in the report.

ReportConfigFilter

The filter expression to be used in the report.

ReportConfigGrouping

The group by expression to be used in the report.

ReportConfigSorting

The order by expression to be used in the report.

ReportConfigSortingType

Direction of sort.

ReportConfigTimePeriod

The start and end date for pulling data for the report.

ReportGranularityType

The granularity of rows in the report.

ReportTimeframeType

The time frame for pulling data for the report. If custom, then a specific time period must be provided.

ReportType

The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates.

View

States and configurations of Cost Analysis.

AccumulatedType

Show costs accumulated over time.

Name Type Description
false

string

true

string

ChartType

Chart type of the main view in Cost Analysis. Required.

Name Type Description
Area

string

GroupedColumn

string

Line

string

StackedColumn

string

Table

string

ErrorDetails

The details of the error.

Name Type Description
code

string

Error code.

message

string

Error message indicating why the operation failed.

ErrorResponse

Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message.

Some Error responses:

  • 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" header.

  • 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" header.

Name Type Description
error

ErrorDetails

The details of the error.

FunctionType

The name of the aggregation function to use.

Name Type Description
Sum

string

KpiProperties

Each KPI must contain a 'type' and 'enabled' key.

Name Type Description
enabled

boolean

show the KPI in the UI?

id

string

ID of resource related to metric (budget).

type

KpiTypeType

KPI type (Forecast, Budget).

KpiTypeType

KPI type (Forecast, Budget).

Name Type Description
Budget

string

Forecast

string

MetricType

Metric to use when displaying costs.

Name Type Description
AHUB

string

ActualCost

string

AmortizedCost

string

OperatorType

The operator to use for comparison.

Name Type Description
Contains

string

In

string

PivotProperties

Each pivot must contain a 'type' and 'name'.

Name Type Description
name

string

Data field to show in view.

type

PivotTypeType

Data type to show in view.

PivotTypeType

Data type to show in view.

Name Type Description
Dimension

string

TagKey

string

QueryColumnType

The type of the column in the export.

Name Type Description
Dimension

string

The dimension of cost data.

TagKey

string

The tag associated with the cost data.

ReportConfigAggregation

The aggregation expression to be used in the report.

Name Type Description
function

FunctionType

The name of the aggregation function to use.

name

string

The name of the column to aggregate.

ReportConfigComparisonExpression

The comparison expression to be used in the report.

Name Type Description
name

string

The name of the column to use in comparison.

operator

OperatorType

The operator to use for comparison.

values

string[]

Array of values to use for comparison

ReportConfigDataset

The definition of data present in the report.

Name Type Description
aggregation

<string,  ReportConfigAggregation>

Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the aggregated column. Report can have up to 2 aggregation clauses.

configuration

ReportConfigDatasetConfiguration

Has configuration information for the data in the report. The configuration will be ignored if aggregation and grouping are provided.

filter

ReportConfigFilter

Has filter expression to use in the report.

granularity

ReportGranularityType

The granularity of rows in the report.

grouping

ReportConfigGrouping[]

Array of group by expression to use in the report. Report can have up to 2 group by clauses.

sorting

ReportConfigSorting[]

Array of order by expression to use in the report.

ReportConfigDatasetConfiguration

The configuration of dataset in the report.

Name Type Description
columns

string[]

Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report includes all columns.

ReportConfigFilter

The filter expression to be used in the report.

Name Type Description
and

ReportConfigFilter[]

The logical "AND" expression. Must have at least 2 items.

dimensions

ReportConfigComparisonExpression

Has comparison expression for a dimension

or

ReportConfigFilter[]

The logical "OR" expression. Must have at least 2 items.

tags

ReportConfigComparisonExpression

Has comparison expression for a tag

ReportConfigGrouping

The group by expression to be used in the report.

Name Type Description
name

string

The name of the column to group. This version supports subscription lowest possible grain.

type

QueryColumnType

Has type of the column to group.

ReportConfigSorting

The order by expression to be used in the report.

Name Type Description
direction

ReportConfigSortingType

Direction of sort.

name

string

The name of the column to sort.

ReportConfigSortingType

Direction of sort.

Name Type Description
Ascending

string

Descending

string

ReportConfigTimePeriod

The start and end date for pulling data for the report.

Name Type Description
from

string

The start date to pull data from.

to

string

The end date to pull data to.

ReportGranularityType

The granularity of rows in the report.

Name Type Description
Daily

string

Monthly

string

ReportTimeframeType

The time frame for pulling data for the report. If custom, then a specific time period must be provided.

Name Type Description
Custom

string

MonthToDate

string

WeekToDate

string

YearToDate

string

ReportType

The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates.

Name Type Description
Usage

string

View

States and configurations of Cost Analysis.

Name Type Description
eTag

string

eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.

id

string

Resource Id.

name

string

Resource name.

properties.accumulated

AccumulatedType

Show costs accumulated over time.

properties.chart

ChartType

Chart type of the main view in Cost Analysis. Required.

properties.createdOn

string

Date the user created this view.

properties.currency

string

Currency of the current view.

properties.dateRange

string

Date range of the current view.

properties.displayName

string

User input name of the view. Required.

properties.kpis

KpiProperties[]

List of KPIs to show in Cost Analysis UI.

properties.metric

MetricType

Metric to use when displaying costs.

properties.modifiedOn

string

Date when the user last modified this view.

properties.pivots

PivotProperties[]

Configuration of 3 sub-views in the Cost Analysis UI.

properties.query.dataSet

ReportConfigDataset

Has definition for data in this report config.

properties.query.includeMonetaryCommitment

boolean

If true, report includes monetary commitment.

properties.query.timePeriod

ReportConfigTimePeriod

Has time period for pulling data for the report.

properties.query.timeframe

ReportTimeframeType

The time frame for pulling data for the report. If custom, then a specific time period must be provided.

properties.query.type

ReportType

The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates.

properties.scope

string

Cost Management scope to save the view on. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription scope.

type

string

Resource type.