Scheduled Actions - Create Or Update By Scope
在给定范围内创建或更新共享的计划操作。
PUT https://management.azure.com/{scope}/providers/Microsoft.CostManagement/scheduledActions/{name}?api-version=2025-03-01
URI 参数
| 名称 | 在 | 必需 | 类型 | 说明 |
|---|---|---|---|---|
|
name
|
path | True |
string |
计划的操作名称。 |
|
scope
|
path | True |
string |
与计划操作操作关联的范围。 这包括订阅范围的“subscriptions/{subscriptionId}”、resourceGroup 范围的“subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}”、 “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/{EnrollmentAccount 范围的 enrollmentAccountId},“providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}” for BillingProfile scope, “providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}” for InvoiceSection scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account scope and 'providers/Microsoft' 。外部订阅范围的 CostManagement/externalSubscriptions/{externalSubscriptionName}' 。 注意:见解警报仅适用于订阅范围。 |
|
api-version
|
query | True |
string minLength: 1 |
用于此操作的 API 版本。 |
请求头
| 名称 | 必需 | 类型 | 说明 |
|---|---|---|---|
| If-Match |
string |
实体的 ETag。 创建实体时不需要。 更新实体时是可选的,可以指定以实现乐观并发。 |
请求正文
| 名称 | 必需 | 类型 | 说明 |
|---|---|---|---|
| properties.displayName | True |
string |
计划的操作名称。 |
| properties.notification | True |
基于计划的操作类型通知属性。 |
|
| properties.schedule | True |
计划操作的计划。 |
|
| properties.status | True |
计划操作的状态。 |
|
| properties.viewId | True |
string |
用于计划操作的成本分析 viewId。 例如,“/providers/Microsoft.CostManagement/views/swaggerExample” |
| kind |
计划的操作的类型。 |
||
| properties.fileDestination |
视图数据的目标格式。 这是可选的。 |
||
| properties.notificationEmail |
string |
应获取取消订阅请求和通知电子邮件的联系人点的电子邮件地址。 |
|
| properties.scope |
string |
对于私有计划作(Create 或 Update),scope 将为空。 |
响应
| 名称 | 类型 | 说明 |
|---|---|---|
| 200 OK |
还行。 请求已成功。 |
|
| 201 Created |
创建。 |
|
| Other Status Codes |
描述操作失败的原因的错误响应。 |
安全性
azure_auth
Azure Active Directory OAuth2 流程。
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
| 名称 | 说明 |
|---|---|
| user_impersonation | 模拟用户帐户 |
示例
|
Create |
|
Create |
CreateOrUpdateInsightAlertScheduledActionByScope
示例请求
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/dailyAnomalyByResource?api-version=2025-03-01
{
"kind": "InsightAlert",
"properties": {
"displayName": "Daily anomaly by resource",
"notification": {
"to": [
"user@gmail.com",
"team@gmail.com"
],
"subject": "Cost anomaly detected in the resource"
},
"schedule": {
"frequency": "Daily",
"startDate": "2020-06-19T22:21:51.1287144Z",
"endDate": "2021-06-19T22:21:51.1287144Z"
},
"status": "Enabled",
"viewId": "/providers/Microsoft.CostManagement/views/swaggerExample"
}
}
示例响应
{
"id": "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/dailyAnomalyByResource",
"name": "dailyAnomalyByResource",
"type": "Microsoft.CostManagement/ScheduledActions",
"kind": "InsightAlert",
"eTag": "\"1d4ff9fe66f1d10\"",
"systemData": {
"createdBy": "testuser",
"createdByType": "User",
"createdAt": "2020-06-18T22:21:51.1287144Z",
"lastModifiedBy": "testuser",
"lastModifiedByType": "User",
"lastModifiedAt": "2020-06-18T22:21:51.1287144Z"
},
"properties": {
"displayName": "Daily anomaly by resource",
"fileDestination": {
"fileFormats": []
},
"notification": {
"to": [
"user@gmail.com",
"team@gmail.com"
],
"subject": "Cost anomaly detected in the resource"
},
"schedule": {
"frequency": "Daily",
"startDate": "2020-06-19T22:21:51.1287144Z",
"endDate": "2021-06-19T22:21:51.1287144Z"
},
"scope": "subscriptions/00000000-0000-0000-0000-000000000000",
"status": "Enabled",
"viewId": "/providers/Microsoft.CostManagement/views/swaggerExample"
}
}
{
"id": "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/dailyAnomalyByResource",
"name": "dailyAnomalyByResource",
"type": "Microsoft.CostManagement/ScheduledActions",
"kind": "InsightAlert",
"eTag": "\"1d4ff9fe66f1d10\"",
"systemData": {
"createdBy": "testuser",
"createdByType": "User",
"createdAt": "2020-06-18T22:21:51.1287144Z",
"lastModifiedBy": "testuser",
"lastModifiedByType": "User",
"lastModifiedAt": "2020-06-19T22:21:51.1287144Z"
},
"properties": {
"displayName": "Daily anomaly by resource",
"fileDestination": {
"fileFormats": []
},
"notification": {
"to": [
"user@gmail.com",
"team@gmail.com"
],
"subject": "Cost anomaly detected in the resource"
},
"scope": "subscriptions/00000000-0000-0000-0000-000000000000",
"schedule": {
"frequency": "Daily",
"startDate": "2020-06-19T22:21:51.1287144Z",
"endDate": "2021-06-19T22:21:51.1287144Z"
},
"status": "Enabled",
"viewId": "/providers/Microsoft.CostManagement/views/swaggerExample"
}
}
CreateOrUpdateScheduledActionByScope
示例请求
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource?api-version=2025-03-01
{
"kind": "Email",
"properties": {
"displayName": "Monthly Cost By Resource",
"fileDestination": {
"fileFormats": [
"Csv"
]
},
"notification": {
"to": [
"user@gmail.com",
"team@gmail.com"
],
"subject": "Cost by resource this month"
},
"schedule": {
"frequency": "Monthly",
"weeksOfMonth": [
"First",
"Third"
],
"daysOfWeek": [
"Monday"
],
"hourOfDay": 10,
"startDate": "2020-06-19T22:21:51.1287144Z",
"endDate": "2021-06-19T22:21:51.1287144Z"
},
"status": "Enabled",
"viewId": "/providers/Microsoft.CostManagement/views/swaggerExample"
}
}
示例响应
{
"id": "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource",
"name": "monthlyCostByResource",
"type": "Microsoft.CostManagement/ScheduledActions",
"kind": "Email",
"eTag": "\"1d4ff9fe66f1d10\"",
"systemData": {
"createdBy": "testuser",
"createdByType": "User",
"createdAt": "2020-06-18T22:21:51.1287144Z",
"lastModifiedBy": "testuser",
"lastModifiedByType": "User",
"lastModifiedAt": "2020-06-18T22:21:51.1287144Z"
},
"properties": {
"displayName": "Monthly Cost By Resource",
"fileDestination": {
"fileFormats": [
"Csv"
]
},
"notification": {
"to": [
"user@gmail.com",
"team@gmail.com"
],
"subject": "Cost by resource this month"
},
"schedule": {
"frequency": "Monthly",
"weeksOfMonth": [
"First",
"Third"
],
"daysOfWeek": [
"Monday"
],
"hourOfDay": 10,
"startDate": "2020-06-19T22:21:51.1287144Z",
"endDate": "2021-06-19T22:21:51.1287144Z"
},
"scope": "subscriptions/00000000-0000-0000-0000-000000000000",
"status": "Enabled",
"viewId": "/providers/Microsoft.CostManagement/views/swaggerExample"
}
}
{
"id": "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource",
"name": "monthlyCostByResource",
"type": "Microsoft.CostManagement/ScheduledActions",
"kind": "Email",
"eTag": "\"1d4ff9fe66f1d10\"",
"systemData": {
"createdBy": "testuser",
"createdByType": "User",
"createdAt": "2020-06-18T22:21:51.1287144Z",
"lastModifiedBy": "testuser",
"lastModifiedByType": "User",
"lastModifiedAt": "2020-06-19T22:21:51.1287144Z"
},
"properties": {
"displayName": "Monthly Cost By Resource",
"notification": {
"to": [
"user@gmail.com",
"team@gmail.com"
],
"subject": "Cost by resource this month"
},
"scope": "subscriptions/00000000-0000-0000-0000-000000000000",
"schedule": {
"frequency": "Monthly",
"weeksOfMonth": [
"First",
"Third"
],
"daysOfWeek": [
"Monday"
],
"hourOfDay": 10,
"startDate": "2020-06-19T22:21:51.1287144Z",
"endDate": "2021-06-19T22:21:51.1287144Z"
},
"status": "Enabled",
"viewId": "/providers/Microsoft.CostManagement/views/swaggerExample"
}
}
定义
| 名称 | 说明 |
|---|---|
|
created |
创建资源的标识的类型。 |
|
Days |
星期几。 |
|
Error |
错误的详细信息。 |
|
Error |
错误响应指示服务无法处理传入请求。 错误消息中提供了原因。 一些错误响应:
|
|
File |
视图数据的目标。 这是可选的。 目前仅支持 CSV 格式。 |
|
File |
视图数据的目标。 目前仅支持 CSV 格式。 |
|
Notification |
计划操作通知的属性。 |
|
Scheduled |
计划的操作定义。 |
|
Scheduled |
计划的操作的类型。 |
|
Scheduled |
计划操作的状态。 |
|
Schedule |
计划的频率。 |
|
Schedule |
计划的属性。 |
|
system |
与创建和上次修改资源相关的元数据。 |
|
Weeks |
月数周。 |
createdByType
创建资源的标识的类型。
| 值 | 说明 |
|---|---|
| User | |
| Application | |
| ManagedIdentity | |
| Key |
DaysOfWeek
星期几。
| 值 | 说明 |
|---|---|
| Monday | |
| Tuesday | |
| Wednesday | |
| Thursday | |
| Friday | |
| Saturday | |
| Sunday |
ErrorDetailsWithNestedDetails
错误的详细信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| code |
string |
错误代码。 |
| details |
错误的其他详细信息。 |
|
| message |
string |
指示操作失败的原因的错误消息。 |
ErrorResponseWithNestedDetails
错误响应指示服务无法处理传入请求。 错误消息中提供了原因。
一些错误响应:
429 TooManyRequests - 请求受到限制。 等待“x-ms-ratelimit-microsoft.consumption-retry-after”标头中指定的时间后重试。
503 ServiceUnavailable - 服务暂时不可用。 在等待“Retry-After”标头中指定的时间后重试。
| 名称 | 类型 | 说明 |
|---|---|---|
| error |
错误的详细信息。 |
FileDestination
视图数据的目标。 这是可选的。 目前仅支持 CSV 格式。
| 名称 | 类型 | 说明 |
|---|---|---|
| fileFormats |
视图数据的目标。 目前仅支持 CSV 格式。 |
FileFormat
视图数据的目标。 目前仅支持 CSV 格式。
| 值 | 说明 |
|---|---|
| Csv |
NotificationProperties
计划操作通知的属性。
| 名称 | 类型 | 说明 |
|---|---|---|
| language |
string |
电子邮件的区域设置。 |
| message |
string |
要添加到电子邮件中的可选邮件。 长度限制为 250 个字符。 |
| regionalFormat |
string |
用于设置电子邮件中日期/时间和货币值的格式的区域格式。 |
| subject |
string |
电子邮件的主题。 长度限制为 70 个字符。 |
| to |
string[] pattern: ^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}$ |
电子邮件地址数组。 |
ScheduledAction
计划的操作定义。
| 名称 | 类型 | 说明 |
|---|---|---|
| eTag |
string |
资源 Etag。 对于更新调用,eTag 是可选的,可以指定以实现乐观并发。 先执行“GET”调用,然后在执行更新时将最新的 eTag 作为请求正文的一部分或“If-Match”标头来提取资源的 eTag。 对于创建调用,不需要 eTag。 |
| id |
string |
资源的完全限定的资源 ID。 示例 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} |
| kind |
计划的操作的类型。 |
|
| name |
string |
资源的名称 |
| properties.displayName |
string |
计划的操作名称。 |
| properties.fileDestination |
视图数据的目标格式。 这是可选的。 |
|
| properties.notification |
基于计划的操作类型通知属性。 |
|
| properties.notificationEmail |
string |
应获取取消订阅请求和通知电子邮件的联系人点的电子邮件地址。 |
| properties.schedule |
计划操作的计划。 |
|
| properties.scope |
string |
对于私有计划作(Create 或 Update),scope 将为空。 |
| properties.status |
计划操作的状态。 |
|
| properties.viewId |
string |
用于计划操作的成本分析 viewId。 例如,“/providers/Microsoft.CostManagement/views/swaggerExample” |
| systemData |
计划的操作的类型。 |
|
| type |
string |
资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts” |
ScheduledActionKind
计划的操作的类型。
| 值 | 说明 |
|---|---|
|
成本分析数据将通过电子邮件发送。 |
|
| InsightAlert |
成本异常信息将通过电子邮件发送。 仅在每日频率的订阅范围内可用。 如果未在资源上检测到异常,则不会发送电子邮件。 |
ScheduledActionStatus
计划操作的状态。
| 值 | 说明 |
|---|---|
| Enabled |
已保存计划操作,将运行。 |
| Expired |
计划操作已过期。 |
| Disabled |
已保存计划操作,但不会运行。 |
ScheduleFrequency
计划的频率。
| 值 | 说明 |
|---|---|
| Daily |
成本分析数据将每天发送电子邮件。 |
| Weekly |
成本分析数据将每周发送电子邮件。 |
| Monthly |
每月都会通过电子邮件发送成本分析数据。 |
ScheduleProperties
计划的属性。
| 名称 | 类型 | 说明 |
|---|---|---|
| dayOfMonth |
integer (int32) |
将通过电子邮件发送成本分析数据的 UTC 日期。 必须介于 1 和 31 之间。 当频率为 Monthly 并重写 weeksOfMonth 或 daysOfWeek 时,此属性适用。 |
| daysOfWeek |
将通过电子邮件发送成本分析数据的英文日期名称。 当频率为每周或每月时,此属性适用。 |
|
| endDate |
string (date-time) |
计划操作(UTC)的结束日期和时间。 |
| frequency |
计划的频率。 |
|
| hourOfDay |
integer (int32) |
将通过电子邮件发送成本分析数据的 UTC 时间。 |
| startDate |
string (date-time) |
计划操作的开始日期和时间(UTC)。 |
| weeksOfMonth |
将通过电子邮件发送成本分析数据的周数。 当频率为 Monthly 且与 daysOfWeek 结合使用时,此属性适用。 |
systemData
与创建和上次修改资源相关的元数据。
| 名称 | 类型 | 说明 |
|---|---|---|
| createdAt |
string (date-time) |
资源创建时间戳(UTC)。 |
| createdBy |
string |
创建资源的标识。 |
| createdByType |
创建资源的标识的类型。 |
|
| lastModifiedAt |
string (date-time) |
上次修改的资源时间戳(UTC) |
| lastModifiedBy |
string |
上次修改资源的标识。 |
| lastModifiedByType |
上次修改资源的标识的类型。 |
WeeksOfMonth
月数周。
| 值 | 说明 |
|---|---|
| First | |
| Second | |
| Third | |
| Fourth | |
| Last |