Create or update a shared scheduled action within the given scope.
PUT https://management.azure.com/{scope}/providers/Microsoft.CostManagement/scheduledActions/{name}?api-version=2025-03-01
URI Parameters
| Name |
In |
Required |
Type |
Description |
|
name
|
path |
True
|
string
|
Scheduled action name.
|
|
scope
|
path |
True
|
string
|
undefined
|
|
api-version
|
query |
True
|
string
minLength: 1
|
The API version to use for this operation.
|
Request Header
| Name |
Required |
Type |
Description |
|
If-Match
|
string
|
ETag of the Entity. Not required when creating an entity. Optional when updating an entity and can be specified to achieve optimistic concurrency.
|
Request Body
| Name |
Required |
Type |
Description |
|
properties.displayName
|
True
|
string
|
Scheduled action name.
|
|
properties.notification
|
True
|
NotificationProperties
|
Notification properties based on scheduled action kind.
|
|
properties.schedule
|
True
|
ScheduleProperties
|
Schedule of the scheduled action.
|
|
properties.status
|
True
|
ScheduledActionStatus
|
Status of the scheduled action.
|
|
properties.viewId
|
True
|
string
|
Cost analysis viewId used for scheduled action. For example, '/providers/Microsoft.CostManagement/views/swaggerExample'
|
|
eTag
|
string
|
Resource Etag. For update calls, eTag is optional and can be specified to achieve optimistic concurrency. Fetch the resource's eTag by doing a 'GET' call first and then including the latest eTag as part of the request body or 'If-Match' header while performing the update. For create calls, eTag is not required.
|
|
kind
|
ScheduledActionKind
|
Kind of the scheduled action.
|
|
properties.fileDestination
|
FileDestination
|
Destination format of the view data. This is optional.
|
|
properties.notificationEmail
|
string
|
Email address of the point of contact that should get the unsubscribe requests and notification emails.
|
|
properties.scope
|
string
|
For private scheduled action(Create or Update), scope will be empty. For shared scheduled action(Create or Update By Scope), Cost Management scope can be '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.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription scope.
|
Responses
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
CreateOrUpdateInsightAlertScheduledActionByScope
Sample request
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": {
"subject": "Cost anomaly detected in the resource",
"to": [
"user@gmail.com",
"team@gmail.com"
]
},
"schedule": {
"endDate": "2021-06-19T22:21:51.1287144Z",
"frequency": "Daily",
"startDate": "2020-06-19T22:21:51.1287144Z"
},
"status": "Enabled",
"viewId": "/providers/Microsoft.CostManagement/views/swaggerExample"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.costmanagement import CostManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-costmanagement
# USAGE
python scheduled_actioninsight_alertcreate_or_updateshared.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = CostManagementClient(
credential=DefaultAzureCredential(),
)
response = client.scheduled_actions.create_or_update_by_scope(
scope="subscriptions/00000000-0000-0000-0000-000000000000",
name="dailyAnomalyByResource",
scheduled_action={
"kind": "InsightAlert",
"properties": {
"displayName": "Daily anomaly by resource",
"notification": {
"subject": "Cost anomaly detected in the resource",
"to": ["user@gmail.com", "team@gmail.com"],
},
"schedule": {
"endDate": "2021-06-19T22:21:51.1287144Z",
"frequency": "Daily",
"startDate": "2020-06-19T22:21:51.1287144Z",
},
"status": "Enabled",
"viewId": "/providers/Microsoft.CostManagement/views/swaggerExample",
},
},
)
print(response)
# x-ms-original-file: 2025-03-01/scheduledActions/scheduledAction-insightAlert-createOrUpdate-shared.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcostmanagement_test
import (
"context"
"log"
"time"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3"
)
// Generated from example definition: 2025-03-01/scheduledActions/scheduledAction-insightAlert-createOrUpdate-shared.json
func ExampleScheduledActionsClient_CreateOrUpdateByScope_createOrUpdateInsightAlertScheduledActionByScope() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcostmanagement.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewScheduledActionsClient().CreateOrUpdateByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "dailyAnomalyByResource", armcostmanagement.ScheduledAction{
Kind: to.Ptr(armcostmanagement.ScheduledActionKindInsightAlert),
Properties: &armcostmanagement.ScheduledActionProperties{
DisplayName: to.Ptr("Daily anomaly by resource"),
Notification: &armcostmanagement.NotificationProperties{
Subject: to.Ptr("Cost anomaly detected in the resource"),
To: []*string{
to.Ptr("user@gmail.com"),
to.Ptr("team@gmail.com"),
},
},
Schedule: &armcostmanagement.ScheduleProperties{
EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.1287144Z"); return t }()),
Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyDaily),
StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.1287144Z"); return t }()),
},
Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled),
ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"),
},
}, &armcostmanagement.ScheduledActionsClientCreateOrUpdateByScopeOptions{
IfMatch: to.Ptr("")})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armcostmanagement.ScheduledActionsClientCreateOrUpdateByScopeResponse{
// ScheduledAction: armcostmanagement.ScheduledAction{
// Name: to.Ptr("dailyAnomalyByResource"),
// Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"),
// ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d10\"")),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/dailyAnomalyByResource"),
// Kind: to.Ptr(armcostmanagement.ScheduledActionKindInsightAlert),
// Properties: &armcostmanagement.ScheduledActionProperties{
// DisplayName: to.Ptr("Daily anomaly by resource"),
// FileDestination: &armcostmanagement.FileDestination{
// FileFormats: []*armcostmanagement.FileFormat{
// },
// },
// Notification: &armcostmanagement.NotificationProperties{
// Subject: to.Ptr("Cost anomaly detected in the resource"),
// To: []*string{
// to.Ptr("user@gmail.com"),
// to.Ptr("team@gmail.com"),
// },
// },
// Schedule: &armcostmanagement.ScheduleProperties{
// EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.1287144Z"); return t}()),
// Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyDaily),
// StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.1287144Z"); return t}()),
// },
// Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"),
// Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled),
// ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"),
// },
// SystemData: &armcostmanagement.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()),
// CreatedBy: to.Ptr("testuser"),
// CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.1287144Z"); return t}()),
// LastModifiedBy: to.Ptr("testuser"),
// LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CostManagementClient } = require("@azure/arm-costmanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update a shared scheduled action within the given scope.
*
* @summary create or update a shared scheduled action within the given scope.
* x-ms-original-file: 2025-03-01/scheduledActions/scheduledAction-insightAlert-createOrUpdate-shared.json
*/
async function createOrUpdateInsightAlertScheduledActionByScope() {
const credential = new DefaultAzureCredential();
const client = new CostManagementClient(credential);
const result = await client.scheduledActions.createOrUpdateByScope(
"subscriptions/00000000-0000-0000-0000-000000000000",
"dailyAnomalyByResource",
{
kind: "InsightAlert",
displayName: "Daily anomaly by resource",
notification: {
subject: "Cost anomaly detected in the resource",
to: ["user@gmail.com", "team@gmail.com"],
},
schedule: {
endDate: new Date("2021-06-19T22:21:51.1287144Z"),
frequency: "Daily",
startDate: new Date("2020-06-19T22:21:51.1287144Z"),
},
status: "Enabled",
viewId: "/providers/Microsoft.CostManagement/views/swaggerExample",
},
{ ifMatch: "" },
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "dailyAnomalyByResource",
"type": "Microsoft.CostManagement/ScheduledActions",
"eTag": "\"1d4ff9fe66f1d10\"",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/dailyAnomalyByResource",
"kind": "InsightAlert",
"properties": {
"displayName": "Daily anomaly by resource",
"fileDestination": {
"fileFormats": []
},
"notification": {
"subject": "Cost anomaly detected in the resource",
"to": [
"user@gmail.com",
"team@gmail.com"
]
},
"schedule": {
"endDate": "2021-06-19T22:21:51.1287144Z",
"frequency": "Daily",
"startDate": "2020-06-19T22:21:51.1287144Z"
},
"scope": "subscriptions/00000000-0000-0000-0000-000000000000",
"status": "Enabled",
"viewId": "/providers/Microsoft.CostManagement/views/swaggerExample"
},
"systemData": {
"createdAt": "2020-06-18T22:21:51.1287144Z",
"createdBy": "testuser",
"createdByType": "User",
"lastModifiedAt": "2020-06-19T22:21:51.1287144Z",
"lastModifiedBy": "testuser",
"lastModifiedByType": "User"
}
}
{
"name": "dailyAnomalyByResource",
"type": "Microsoft.CostManagement/ScheduledActions",
"eTag": "\"1d4ff9fe66f1d10\"",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/dailyAnomalyByResource",
"kind": "InsightAlert",
"properties": {
"displayName": "Daily anomaly by resource",
"fileDestination": {
"fileFormats": []
},
"notification": {
"subject": "Cost anomaly detected in the resource",
"to": [
"user@gmail.com",
"team@gmail.com"
]
},
"schedule": {
"endDate": "2021-06-19T22:21:51.1287144Z",
"frequency": "Daily",
"startDate": "2020-06-19T22:21:51.1287144Z"
},
"scope": "subscriptions/00000000-0000-0000-0000-000000000000",
"status": "Enabled",
"viewId": "/providers/Microsoft.CostManagement/views/swaggerExample"
},
"systemData": {
"createdAt": "2020-06-18T22:21:51.1287144Z",
"createdBy": "testuser",
"createdByType": "User",
"lastModifiedAt": "2020-06-18T22:21:51.1287144Z",
"lastModifiedBy": "testuser",
"lastModifiedByType": "User"
}
}
CreateOrUpdateScheduledActionByScope
Sample request
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": {
"subject": "Cost by resource this month",
"to": [
"user@gmail.com",
"team@gmail.com"
]
},
"schedule": {
"daysOfWeek": [
"Monday"
],
"endDate": "2021-06-19T22:21:51.1287144Z",
"frequency": "Monthly",
"hourOfDay": 10,
"startDate": "2020-06-19T22:21:51.1287144Z",
"weeksOfMonth": [
"First",
"Third"
]
},
"status": "Enabled",
"viewId": "/providers/Microsoft.CostManagement/views/swaggerExample"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.costmanagement import CostManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-costmanagement
# USAGE
python scheduled_actioncreate_or_updateshared.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = CostManagementClient(
credential=DefaultAzureCredential(),
)
response = client.scheduled_actions.create_or_update_by_scope(
scope="subscriptions/00000000-0000-0000-0000-000000000000",
name="monthlyCostByResource",
scheduled_action={
"kind": "Email",
"properties": {
"displayName": "Monthly Cost By Resource",
"fileDestination": {"fileFormats": ["Csv"]},
"notification": {"subject": "Cost by resource this month", "to": ["user@gmail.com", "team@gmail.com"]},
"schedule": {
"daysOfWeek": ["Monday"],
"endDate": "2021-06-19T22:21:51.1287144Z",
"frequency": "Monthly",
"hourOfDay": 10,
"startDate": "2020-06-19T22:21:51.1287144Z",
"weeksOfMonth": ["First", "Third"],
},
"status": "Enabled",
"viewId": "/providers/Microsoft.CostManagement/views/swaggerExample",
},
},
)
print(response)
# x-ms-original-file: 2025-03-01/scheduledActions/scheduledAction-createOrUpdate-shared.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcostmanagement_test
import (
"context"
"log"
"time"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3"
)
// Generated from example definition: 2025-03-01/scheduledActions/scheduledAction-createOrUpdate-shared.json
func ExampleScheduledActionsClient_CreateOrUpdateByScope_createOrUpdateScheduledActionByScope() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcostmanagement.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewScheduledActionsClient().CreateOrUpdateByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "monthlyCostByResource", armcostmanagement.ScheduledAction{
Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail),
Properties: &armcostmanagement.ScheduledActionProperties{
DisplayName: to.Ptr("Monthly Cost By Resource"),
FileDestination: &armcostmanagement.FileDestination{
FileFormats: []*armcostmanagement.FileFormat{
to.Ptr(armcostmanagement.FileFormatCSV),
},
},
Notification: &armcostmanagement.NotificationProperties{
Subject: to.Ptr("Cost by resource this month"),
To: []*string{
to.Ptr("user@gmail.com"),
to.Ptr("team@gmail.com"),
},
},
Schedule: &armcostmanagement.ScheduleProperties{
DaysOfWeek: []*armcostmanagement.DaysOfWeek{
to.Ptr(armcostmanagement.DaysOfWeekMonday),
},
EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.1287144Z"); return t }()),
Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyMonthly),
HourOfDay: to.Ptr[int32](10),
StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.1287144Z"); return t }()),
WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{
to.Ptr(armcostmanagement.WeeksOfMonthFirst),
to.Ptr(armcostmanagement.WeeksOfMonthThird),
},
},
Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled),
ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"),
},
}, &armcostmanagement.ScheduledActionsClientCreateOrUpdateByScopeOptions{
IfMatch: to.Ptr("")})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armcostmanagement.ScheduledActionsClientCreateOrUpdateByScopeResponse{
// ScheduledAction: armcostmanagement.ScheduledAction{
// Name: to.Ptr("monthlyCostByResource"),
// Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"),
// ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d10\"")),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"),
// Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail),
// Properties: &armcostmanagement.ScheduledActionProperties{
// DisplayName: to.Ptr("Monthly Cost By Resource"),
// Notification: &armcostmanagement.NotificationProperties{
// Subject: to.Ptr("Cost by resource this month"),
// To: []*string{
// to.Ptr("user@gmail.com"),
// to.Ptr("team@gmail.com"),
// },
// },
// Schedule: &armcostmanagement.ScheduleProperties{
// DaysOfWeek: []*armcostmanagement.DaysOfWeek{
// to.Ptr(armcostmanagement.DaysOfWeekMonday),
// },
// EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.1287144Z"); return t}()),
// Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyMonthly),
// HourOfDay: to.Ptr[int32](10),
// StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.1287144Z"); return t}()),
// WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{
// to.Ptr(armcostmanagement.WeeksOfMonthFirst),
// to.Ptr(armcostmanagement.WeeksOfMonthThird),
// },
// },
// Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"),
// Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled),
// ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"),
// },
// SystemData: &armcostmanagement.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()),
// CreatedBy: to.Ptr("testuser"),
// CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.1287144Z"); return t}()),
// LastModifiedBy: to.Ptr("testuser"),
// LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CostManagementClient } = require("@azure/arm-costmanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update a shared scheduled action within the given scope.
*
* @summary create or update a shared scheduled action within the given scope.
* x-ms-original-file: 2025-03-01/scheduledActions/scheduledAction-createOrUpdate-shared.json
*/
async function createOrUpdateScheduledActionByScope() {
const credential = new DefaultAzureCredential();
const client = new CostManagementClient(credential);
const result = await client.scheduledActions.createOrUpdateByScope(
"subscriptions/00000000-0000-0000-0000-000000000000",
"monthlyCostByResource",
{
kind: "Email",
displayName: "Monthly Cost By Resource",
fileDestination: { fileFormats: ["Csv"] },
notification: {
subject: "Cost by resource this month",
to: ["user@gmail.com", "team@gmail.com"],
},
schedule: {
daysOfWeek: ["Monday"],
endDate: new Date("2021-06-19T22:21:51.1287144Z"),
frequency: "Monthly",
hourOfDay: 10,
startDate: new Date("2020-06-19T22:21:51.1287144Z"),
weeksOfMonth: ["First", "Third"],
},
status: "Enabled",
viewId: "/providers/Microsoft.CostManagement/views/swaggerExample",
},
{ ifMatch: "" },
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "monthlyCostByResource",
"type": "Microsoft.CostManagement/ScheduledActions",
"eTag": "\"1d4ff9fe66f1d10\"",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource",
"kind": "Email",
"properties": {
"displayName": "Monthly Cost By Resource",
"notification": {
"subject": "Cost by resource this month",
"to": [
"user@gmail.com",
"team@gmail.com"
]
},
"schedule": {
"daysOfWeek": [
"Monday"
],
"endDate": "2021-06-19T22:21:51.1287144Z",
"frequency": "Monthly",
"hourOfDay": 10,
"startDate": "2020-06-19T22:21:51.1287144Z",
"weeksOfMonth": [
"First",
"Third"
]
},
"scope": "subscriptions/00000000-0000-0000-0000-000000000000",
"status": "Enabled",
"viewId": "/providers/Microsoft.CostManagement/views/swaggerExample"
},
"systemData": {
"createdAt": "2020-06-18T22:21:51.1287144Z",
"createdBy": "testuser",
"createdByType": "User",
"lastModifiedAt": "2020-06-19T22:21:51.1287144Z",
"lastModifiedBy": "testuser",
"lastModifiedByType": "User"
}
}
{
"name": "monthlyCostByResource",
"type": "Microsoft.CostManagement/ScheduledActions",
"eTag": "\"1d4ff9fe66f1d10\"",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource",
"kind": "Email",
"properties": {
"displayName": "Monthly Cost By Resource",
"fileDestination": {
"fileFormats": [
"Csv"
]
},
"notification": {
"subject": "Cost by resource this month",
"to": [
"user@gmail.com",
"team@gmail.com"
]
},
"schedule": {
"daysOfWeek": [
"Monday"
],
"endDate": "2021-06-19T22:21:51.1287144Z",
"frequency": "Monthly",
"hourOfDay": 10,
"startDate": "2020-06-19T22:21:51.1287144Z",
"weeksOfMonth": [
"First",
"Third"
]
},
"scope": "subscriptions/00000000-0000-0000-0000-000000000000",
"status": "Enabled",
"viewId": "/providers/Microsoft.CostManagement/views/swaggerExample"
},
"systemData": {
"createdAt": "2020-06-18T22:21:51.1287144Z",
"createdBy": "testuser",
"createdByType": "User",
"lastModifiedAt": "2020-06-18T22:21:51.1287144Z",
"lastModifiedBy": "testuser",
"lastModifiedByType": "User"
}
}
Definitions
| Name |
Description |
|
createdByType
|
The type of identity that created the resource.
|
|
DaysOfWeek
|
Days of Week.
|
|
ErrorDetailsWithNestedDetails
|
The details of the error.
|
|
ErrorResponseWithNestedDetails
|
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.
|
|
FileDestination
|
Destination of the view data. This is optional. Currently only CSV format is supported.
|
|
FileFormat
|
Destination of the view data. Currently only CSV format is supported.
|
|
NotificationProperties
|
The properties of the scheduled action notification.
|
|
ScheduledAction
|
Scheduled action definition.
|
|
ScheduledActionKind
|
Kind of the scheduled action.
|
|
ScheduledActionStatus
|
Status of the scheduled action.
|
|
ScheduleFrequency
|
Frequency of the schedule.
|
|
ScheduleProperties
|
The properties of the schedule.
|
|
systemData
|
Metadata pertaining to creation and last modification of the resource.
|
|
WeeksOfMonth
|
Weeks of month.
|
createdByType
Enumeration
The type of identity that created the resource.
| Value |
Description |
|
User
|
|
Application
|
|
ManagedIdentity
|
|
Key
|
DaysOfWeek
Enumeration
Days of Week.
| Value |
Description |
|
Monday
|
|
Tuesday
|
|
Wednesday
|
|
Thursday
|
|
Friday
|
|
Saturday
|
|
Sunday
|
ErrorDetailsWithNestedDetails
Object
The details of the error.
| Name |
Type |
Description |
|
code
|
string
|
Error code.
|
|
details
|
ErrorDetailsWithNestedDetails[]
|
The additional details of the error.
|
|
message
|
string
|
Error message indicating why the operation failed.
|
ErrorResponseWithNestedDetails
Object
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.
FileDestination
Object
Destination of the view data. This is optional. Currently only CSV format is supported.
| Name |
Type |
Description |
|
fileFormats
|
FileFormat[]
|
Destination of the view data. Currently only CSV format is supported.
|
Enumeration
Destination of the view data. Currently only CSV format is supported.
NotificationProperties
Object
The properties of the scheduled action notification.
| Name |
Type |
Description |
|
language
|
string
|
Locale of the email.
|
|
message
|
string
|
Optional message to be added in the email. Length is limited to 250 characters.
|
|
regionalFormat
|
string
|
Regional format used for formatting date/time and currency values in the email.
|
|
subject
|
string
|
Subject of the email. Length is limited to 70 characters.
|
|
to
|
string[]
|
Array of email addresses.
|
ScheduledAction
Object
Scheduled action definition.
| Name |
Type |
Description |
|
eTag
|
string
|
Resource Etag. For update calls, eTag is optional and can be specified to achieve optimistic concurrency. Fetch the resource's eTag by doing a 'GET' call first and then including the latest eTag as part of the request body or 'If-Match' header while performing the update. For create calls, eTag is not required.
|
|
id
|
string
(arm-id)
|
Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
kind
|
ScheduledActionKind
|
Kind of the scheduled action.
|
|
name
|
string
|
The name of the resource
|
|
properties.displayName
|
string
|
Scheduled action name.
|
|
properties.fileDestination
|
FileDestination
|
Destination format of the view data. This is optional.
|
|
properties.notification
|
NotificationProperties
|
Notification properties based on scheduled action kind.
|
|
properties.notificationEmail
|
string
|
Email address of the point of contact that should get the unsubscribe requests and notification emails.
|
|
properties.schedule
|
ScheduleProperties
|
Schedule of the scheduled action.
|
|
properties.scope
|
string
|
For private scheduled action(Create or Update), scope will be empty. For shared scheduled action(Create or Update By Scope), Cost Management scope can be '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.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription scope.
|
|
properties.status
|
ScheduledActionStatus
|
Status of the scheduled action.
|
|
properties.viewId
|
string
|
Cost analysis viewId used for scheduled action. For example, '/providers/Microsoft.CostManagement/views/swaggerExample'
|
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
ScheduledActionKind
Enumeration
Kind of the scheduled action.
| Value |
Description |
|
Email
|
Cost analysis data will be emailed.
|
|
InsightAlert
|
Cost anomaly information will be emailed. Available only on subscription scope at daily frequency. If no anomaly is detected on the resource, an email won't be sent.
|
ScheduledActionStatus
Enumeration
Status of the scheduled action.
| Value |
Description |
|
Enabled
|
Scheduled action is saved and will be run.
|
|
Expired
|
Scheduled action is expired.
|
|
Disabled
|
Scheduled action is saved but will not be run.
|
ScheduleFrequency
Enumeration
Frequency of the schedule.
| Value |
Description |
|
Daily
|
Cost analysis data will be emailed every day.
|
|
Weekly
|
Cost analysis data will be emailed every week.
|
|
Monthly
|
Cost analysis data will be emailed every month.
|
ScheduleProperties
Object
The properties of the schedule.
| Name |
Type |
Description |
|
dayOfMonth
|
integer
(int32)
|
UTC day on which cost analysis data will be emailed. Must be between 1 and 31. This property is applicable when frequency is Monthly and overrides weeksOfMonth or daysOfWeek.
|
|
daysOfWeek
|
DaysOfWeek[]
|
Day names in english on which cost analysis data will be emailed. This property is applicable when frequency is Weekly or Monthly.
|
|
endDate
|
string
(date-time)
|
The end date and time of the scheduled action (UTC).
|
|
frequency
|
ScheduleFrequency
|
Frequency of the schedule.
|
|
hourOfDay
|
integer
(int32)
|
UTC time at which cost analysis data will be emailed.
|
|
startDate
|
string
(date-time)
|
The start date and time of the scheduled action (UTC).
|
|
weeksOfMonth
|
WeeksOfMonth[]
|
Weeks in which cost analysis data will be emailed. This property is applicable when frequency is Monthly and used in combination with daysOfWeek.
|
systemData
Object
Metadata pertaining to creation and last modification of the resource.
| Name |
Type |
Description |
|
createdAt
|
string
(date-time)
|
The timestamp of resource creation (UTC).
|
|
createdBy
|
string
|
The identity that created the resource.
|
|
createdByType
|
createdByType
|
The type of identity that created the resource.
|
|
lastModifiedAt
|
string
(date-time)
|
The timestamp of resource last modification (UTC)
|
|
lastModifiedBy
|
string
|
The identity that last modified the resource.
|
|
lastModifiedByType
|
createdByType
|
The type of identity that last modified the resource.
|
WeeksOfMonth
Enumeration
Weeks of month.
| Value |
Description |
|
First
|
|
Second
|
|
Third
|
|
Fourth
|
|
Last
|