Erstellt oder ändert eine Sicherungsrichtlinie. Dies ist ein asynchroner Vorgang. Der Status des Vorgangs kann mithilfe der GetPolicyOperationResult-API abgerufen werden.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupPolicies/{policyName}?api-version=2026-07-01
URI-Parameter
| Name |
In |
Erforderlich |
Typ |
Beschreibung |
|
policyName
|
path |
True
|
string
|
Abzurufende Informationen zur Sicherungsrichtlinie.
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
Der Name der Ressourcengruppe. Bei dem Namen wird die Groß-/Kleinschreibung nicht beachtet.
|
|
subscriptionId
|
path |
True
|
string
minLength: 1
|
Die ID des Zielabonnements.
|
|
vaultName
|
path |
True
|
string
|
Der Name der VaultResource.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
Die API-Version, die für diesen Vorgang verwendet werden soll.
|
| Name |
Erforderlich |
Typ |
Beschreibung |
|
x-ms-authorization-auxiliary
|
|
string
|
|
Anforderungstext
| Name |
Typ |
Beschreibung |
|
eTag
|
string
|
Optionales ETag.
|
|
location
|
string
|
Der geografische Standort, an dem sich die Ressource befindet
|
|
properties
|
ProtectionPolicy:
|
ProtectionPolicyResource Eigenschaften
|
|
tags
|
object
|
Ressourcenkennzeichnungen.
|
Antworten
| Name |
Typ |
Beschreibung |
|
200 OK
|
ProtectionPolicyResource
|
Der Aktualisierungsvorgang "ProtectionPolicyResource" der Ressource war erfolgreich
|
|
202 Accepted
|
|
Die Anforderung wurde zur Verarbeitung akzeptiert, die Verarbeitung wurde jedoch noch nicht abgeschlossen.
|
|
Other Status Codes
|
ErrorResponse
|
Unerwartete Fehlerantwort.
|
Sicherheit
azure_auth
Azure Active Directory OAuth2 Flow.
Typ:
oauth2
Ablauf:
implicit
Autorisierungs-URL:
https://login.microsoftonline.com/common/oauth2/authorize
Bereiche
| Name |
Beschreibung |
|
user_impersonation
|
Sich als Ihr Benutzerkonto ausgeben
|
Beispiele
Create or Update Azure Storage Vault Standard Protection Policy
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/newPolicyV2?api-version=2026-07-01
{
"properties": {
"backupManagementType": "AzureStorage",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": [
"2023-07-18T09:30:00.000Z"
]
},
"timeZone": "UTC",
"vaultRetentionPolicy": {
"snapshotRetentionInDays": 5,
"vaultRetention": {
"dailySchedule": {
"retentionDuration": {
"count": 30,
"durationType": "Days"
},
"retentionTimes": [
"2023-07-18T09:30:00.000Z"
]
},
"monthlySchedule": {
"retentionDuration": {
"count": 60,
"durationType": "Months"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2023-07-18T09:30:00.000Z"
]
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
},
"retentionTimes": [
"2023-07-18T09:30:00.000Z"
]
},
"yearlySchedule": {
"monthsOfYear": [
"January"
],
"retentionDuration": {
"count": 10,
"durationType": "Years"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2023-07-18T09:30:00.000Z"
]
}
}
},
"workLoadType": "AzureFileShare"
}
}
import com.azure.resourcemanager.recoveryservicesbackup.models.AzureFileShareProtectionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.DailyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.DayOfWeek;
import com.azure.resourcemanager.recoveryservicesbackup.models.LongTermRetentionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.MonthOfYear;
import com.azure.resourcemanager.recoveryservicesbackup.models.MonthlyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDuration;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDurationType;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionScheduleFormat;
import com.azure.resourcemanager.recoveryservicesbackup.models.ScheduleRunType;
import com.azure.resourcemanager.recoveryservicesbackup.models.SimpleSchedulePolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.VaultRetentionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeekOfMonth;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionFormat;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.WorkloadType;
import com.azure.resourcemanager.recoveryservicesbackup.models.YearlyRetentionSchedule;
import java.time.OffsetDateTime;
import java.util.Arrays;
/**
* Samples for ProtectionPolicies CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/AzureStorage/ProtectionPolicies_CreateOrUpdate_Hardened.json
*/
/**
* Sample code: Create or Update Azure Storage Vault Standard Protection Policy.
*
* @param manager Entry point to RecoveryServicesBackupManager.
*/
public static void createOrUpdateAzureStorageVaultStandardProtectionPolicy(
com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager manager) {
manager
.protectionPolicies().define(
"newPolicyV2")
.withExistingVault("swaggertestvault",
"SwaggerTestRg")
.withProperties(
new AzureFileShareProtectionPolicy()
.withWorkLoadType(
WorkloadType.AZURE_FILE_SHARE)
.withSchedulePolicy(new SimpleSchedulePolicy()
.withScheduleRunFrequency(ScheduleRunType.DAILY)
.withScheduleRunTimes(Arrays.asList(OffsetDateTime.parse("2023-07-18T09:30:00.000Z"))))
.withVaultRetentionPolicy(
new VaultRetentionPolicy().withVaultRetention(
new LongTermRetentionPolicy()
.withDailySchedule(new DailyRetentionSchedule()
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2023-07-18T09:30:00.000Z")))
.withRetentionDuration(new RetentionDuration().withCount(30)
.withDurationType(RetentionDurationType.DAYS)))
.withWeeklySchedule(new WeeklyRetentionSchedule()
.withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2023-07-18T09:30:00.000Z")))
.withRetentionDuration(new RetentionDuration().withCount(12)
.withDurationType(RetentionDurationType.WEEKS)))
.withMonthlySchedule(
new MonthlyRetentionSchedule()
.withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY)
.withRetentionScheduleWeekly(new WeeklyRetentionFormat()
.withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.FIRST)))
.withRetentionTimes(
Arrays.asList(OffsetDateTime.parse("2023-07-18T09:30:00.000Z")))
.withRetentionDuration(new RetentionDuration().withCount(60)
.withDurationType(RetentionDurationType.MONTHS)))
.withYearlySchedule(
new YearlyRetentionSchedule()
.withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY)
.withMonthsOfYear(Arrays.asList(MonthOfYear.JANUARY))
.withRetentionScheduleWeekly(new WeeklyRetentionFormat()
.withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.FIRST)))
.withRetentionTimes(
Arrays.asList(OffsetDateTime.parse("2023-07-18T09:30:00.000Z")))
.withRetentionDuration(new RetentionDuration().withCount(10)
.withDurationType(RetentionDurationType.YEARS))))
.withSnapshotRetentionInDays(5))
.withTimeZone("UTC"))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.recoveryservicesbackup import RecoveryServicesBackupClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-recoveryservicesbackup
# USAGE
python protection_policies_create_or_update_hardened.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 = RecoveryServicesBackupClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.protection_policies.create_or_update(
vault_name="swaggertestvault",
resource_group_name="SwaggerTestRg",
policy_name="newPolicyV2",
parameters={
"properties": {
"backupManagementType": "AzureStorage",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": ["2023-07-18T09:30:00.000Z"],
},
"timeZone": "UTC",
"vaultRetentionPolicy": {
"snapshotRetentionInDays": 5,
"vaultRetention": {
"dailySchedule": {
"retentionDuration": {"count": 30, "durationType": "Days"},
"retentionTimes": ["2023-07-18T09:30:00.000Z"],
},
"monthlySchedule": {
"retentionDuration": {"count": 60, "durationType": "Months"},
"retentionScheduleDaily": None,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {"daysOfTheWeek": ["Sunday"], "weeksOfTheMonth": ["First"]},
"retentionTimes": ["2023-07-18T09:30:00.000Z"],
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": ["Sunday"],
"retentionDuration": {"count": 12, "durationType": "Weeks"},
"retentionTimes": ["2023-07-18T09:30:00.000Z"],
},
"yearlySchedule": {
"monthsOfYear": ["January"],
"retentionDuration": {"count": 10, "durationType": "Years"},
"retentionScheduleDaily": None,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {"daysOfTheWeek": ["Sunday"], "weeksOfTheMonth": ["First"]},
"retentionTimes": ["2023-07-18T09:30:00.000Z"],
},
},
},
"workLoadType": "AzureFileShare",
}
},
)
print(response)
# x-ms-original-file: 2026-07-01/AzureStorage/ProtectionPolicies_CreateOrUpdate_Hardened.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 armrecoveryservicesbackup_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/recoveryservices/armrecoveryservicesbackup/v5"
)
// Generated from example definition: 2026-07-01/AzureStorage/ProtectionPolicies_CreateOrUpdate_Hardened.json
func ExampleProtectionPoliciesClient_CreateOrUpdate_createOrUpdateAzureStorageVaultStandardProtectionPolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armrecoveryservicesbackup.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewProtectionPoliciesClient().CreateOrUpdate(ctx, "swaggertestvault", "SwaggerTestRg", "newPolicyV2", armrecoveryservicesbackup.ProtectionPolicyResource{
Properties: &armrecoveryservicesbackup.AzureFileShareProtectionPolicy{
BackupManagementType: to.Ptr("AzureStorage"),
SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeDaily),
ScheduleRunTimes: []*time.Time{
to.Ptr(time.Date(2023, time.July, 18, 9, 30, 0, 0, time.UTC)),
},
},
TimeZone: to.Ptr("UTC"),
VaultRetentionPolicy: &armrecoveryservicesbackup.VaultRetentionPolicy{
SnapshotRetentionInDays: to.Ptr[int32](5),
VaultRetention: &armrecoveryservicesbackup.LongTermRetentionPolicy{
DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](30),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2023, time.July, 18, 9, 30, 0, 0, time.UTC)),
},
},
MonthlySchedule: &armrecoveryservicesbackup.MonthlyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](60),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeMonths),
},
RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
},
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2023, time.July, 18, 9, 30, 0, 0, time.UTC)),
},
},
RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
WeeklySchedule: &armrecoveryservicesbackup.WeeklyRetentionSchedule{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](12),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeWeeks),
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2023, time.July, 18, 9, 30, 0, 0, time.UTC)),
},
},
YearlySchedule: &armrecoveryservicesbackup.YearlyRetentionSchedule{
MonthsOfYear: []*armrecoveryservicesbackup.MonthOfYear{
to.Ptr(armrecoveryservicesbackup.MonthOfYearJanuary),
},
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](10),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeYears),
},
RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
},
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2023, time.July, 18, 9, 30, 0, 0, time.UTC)),
},
},
},
},
WorkLoadType: to.Ptr(armrecoveryservicesbackup.WorkloadTypeAzureFileShare),
},
}, nil)
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 = armrecoveryservicesbackup.ProtectionPoliciesClientCreateOrUpdateResponse{
// ProtectionPolicyResource: armrecoveryservicesbackup.ProtectionPolicyResource{
// Name: to.Ptr("newPolicyV2"),
// Type: to.Ptr("Microsoft.RecoveryServices/vaults/backupPolicies"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/newPolicyV2"),
// Properties: &armrecoveryservicesbackup.AzureFileShareProtectionPolicy{
// BackupManagementType: to.Ptr("AzureStorage"),
// ProtectedItemsCount: to.Ptr[int32](0),
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
// ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeDaily),
// ScheduleRunTimes: []*time.Time{
// to.Ptr(time.Date(2023, time.July, 18, 9, 30, 0, 0, time.UTC)),
// },
// },
// TimeZone: to.Ptr("UTC"),
// VaultRetentionPolicy: &armrecoveryservicesbackup.VaultRetentionPolicy{
// SnapshotRetentionInDays: to.Ptr[int32](5),
// VaultRetention: &armrecoveryservicesbackup.LongTermRetentionPolicy{
// DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](30),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2023, time.July, 18, 9, 30, 0, 0, time.UTC)),
// },
// },
// MonthlySchedule: &armrecoveryservicesbackup.MonthlyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](60),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeMonths),
// },
// RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
// RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
// },
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2023, time.July, 18, 9, 30, 0, 0, time.UTC)),
// },
// },
// RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
// WeeklySchedule: &armrecoveryservicesbackup.WeeklyRetentionSchedule{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](12),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeWeeks),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2023, time.July, 18, 9, 30, 0, 0, time.UTC)),
// },
// },
// YearlySchedule: &armrecoveryservicesbackup.YearlyRetentionSchedule{
// MonthsOfYear: []*armrecoveryservicesbackup.MonthOfYear{
// to.Ptr(armrecoveryservicesbackup.MonthOfYearJanuary),
// },
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](10),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeYears),
// },
// RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
// RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
// },
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2023, time.July, 18, 9, 30, 0, 0, time.UTC)),
// },
// },
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { RecoveryServicesBackupClient } = require("@azure/arm-recoveryservicesbackup");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
*
* @summary creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
* x-ms-original-file: 2026-07-01/AzureStorage/ProtectionPolicies_CreateOrUpdate_Hardened.json
*/
async function createOrUpdateAzureStorageVaultStandardProtectionPolicy() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
"swaggertestvault",
"SwaggerTestRg",
"newPolicyV2",
{
properties: {
backupManagementType: "AzureStorage",
schedulePolicy: {
schedulePolicyType: "SimpleSchedulePolicy",
scheduleRunFrequency: "Daily",
scheduleRunTimes: [new Date("2023-07-18T09:30:00.000Z")],
},
timeZone: "UTC",
vaultRetentionPolicy: {
snapshotRetentionInDays: 5,
vaultRetention: {
dailySchedule: {
retentionDuration: { count: 30, durationType: "Days" },
retentionTimes: [new Date("2023-07-18T09:30:00.000Z")],
},
monthlySchedule: {
retentionDuration: { count: 60, durationType: "Months" },
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: { daysOfTheWeek: ["Sunday"], weeksOfTheMonth: ["First"] },
retentionTimes: [new Date("2023-07-18T09:30:00.000Z")],
},
retentionPolicyType: "LongTermRetentionPolicy",
weeklySchedule: {
daysOfTheWeek: ["Sunday"],
retentionDuration: { count: 12, durationType: "Weeks" },
retentionTimes: [new Date("2023-07-18T09:30:00.000Z")],
},
yearlySchedule: {
monthsOfYear: ["January"],
retentionDuration: { count: 10, durationType: "Years" },
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: { daysOfTheWeek: ["Sunday"], weeksOfTheMonth: ["First"] },
retentionTimes: [new Date("2023-07-18T09:30:00.000Z")],
},
},
},
workLoadType: "AzureFileShare",
},
},
);
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
Beispiel für eine Antwort
{
"name": "newPolicyV2",
"type": "Microsoft.RecoveryServices/vaults/backupPolicies",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/newPolicyV2",
"properties": {
"backupManagementType": "AzureStorage",
"protectedItemsCount": 0,
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": [
"2023-07-18T09:30:00.000Z"
]
},
"timeZone": "UTC",
"vaultRetentionPolicy": {
"snapshotRetentionInDays": 5,
"vaultRetention": {
"dailySchedule": {
"retentionDuration": {
"count": 30,
"durationType": "Days"
},
"retentionTimes": [
"2023-07-18T09:30:00.000Z"
]
},
"monthlySchedule": {
"retentionDuration": {
"count": 60,
"durationType": "Months"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2023-07-18T09:30:00.000Z"
]
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
},
"retentionTimes": [
"2023-07-18T09:30:00.000Z"
]
},
"yearlySchedule": {
"monthsOfYear": [
"January"
],
"retentionDuration": {
"count": 10,
"durationType": "Years"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2023-07-18T09:30:00.000Z"
]
}
}
}
}
}
Azure-AsyncOperation: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/newPolicyV2/operations/00000000-0000-0000-0000-000000000000?api-version=2025-02-01
Location: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/newPolicyV2/operationResults/00000000-0000-0000-0000-000000000000?api-version=2025-02-01
Retry-After: 60
Create or Update Daily Azure Storage Protection Policy
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/dailyPolicy2?api-version=2026-07-01
{
"properties": {
"backupManagementType": "AzureStorage",
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {
"count": 5,
"durationType": "Days"
},
"retentionTimes": [
"2021-09-29T08:00:00.000Z"
]
},
"monthlySchedule": {
"retentionDuration": {
"count": 60,
"durationType": "Months"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-09-29T08:00:00.000Z"
]
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
},
"retentionTimes": [
"2021-09-29T08:00:00.000Z"
]
},
"yearlySchedule": {
"monthsOfYear": [
"January"
],
"retentionDuration": {
"count": 10,
"durationType": "Years"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-09-29T08:00:00.000Z"
]
}
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": [
"2021-09-29T08:00:00.000Z"
]
},
"timeZone": "UTC",
"workLoadType": "AzureFileShare"
}
}
import com.azure.resourcemanager.recoveryservicesbackup.models.AzureFileShareProtectionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.DailyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.DayOfWeek;
import com.azure.resourcemanager.recoveryservicesbackup.models.LongTermRetentionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.MonthOfYear;
import com.azure.resourcemanager.recoveryservicesbackup.models.MonthlyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDuration;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDurationType;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionScheduleFormat;
import com.azure.resourcemanager.recoveryservicesbackup.models.ScheduleRunType;
import com.azure.resourcemanager.recoveryservicesbackup.models.SimpleSchedulePolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeekOfMonth;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionFormat;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.WorkloadType;
import com.azure.resourcemanager.recoveryservicesbackup.models.YearlyRetentionSchedule;
import java.time.OffsetDateTime;
import java.util.Arrays;
/**
* Samples for ProtectionPolicies CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/AzureStorage/ProtectionPolicies_CreateOrUpdate_Daily.json
*/
/**
* Sample code: Create or Update Daily Azure Storage Protection Policy.
*
* @param manager Entry point to RecoveryServicesBackupManager.
*/
public static void createOrUpdateDailyAzureStorageProtectionPolicy(
com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager manager) {
manager
.protectionPolicies().define("dailyPolicy2").withExistingVault("swaggertestvault",
"SwaggerTestRg")
.withProperties(new AzureFileShareProtectionPolicy().withWorkLoadType(WorkloadType.AZURE_FILE_SHARE)
.withSchedulePolicy(
new SimpleSchedulePolicy().withScheduleRunFrequency(ScheduleRunType.DAILY).withScheduleRunTimes(
Arrays.asList(OffsetDateTime.parse("2021-09-29T08:00:00.000Z"))))
.withRetentionPolicy(new LongTermRetentionPolicy()
.withDailySchedule(new DailyRetentionSchedule()
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2021-09-29T08:00:00.000Z")))
.withRetentionDuration(
new RetentionDuration().withCount(5).withDurationType(RetentionDurationType.DAYS)))
.withWeeklySchedule(new WeeklyRetentionSchedule().withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2021-09-29T08:00:00.000Z")))
.withRetentionDuration(
new RetentionDuration().withCount(12).withDurationType(RetentionDurationType.WEEKS)))
.withMonthlySchedule(
new MonthlyRetentionSchedule().withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY)
.withRetentionScheduleWeekly(
new WeeklyRetentionFormat().withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.FIRST)))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2021-09-29T08:00:00.000Z")))
.withRetentionDuration(
new RetentionDuration().withCount(60).withDurationType(RetentionDurationType.MONTHS)))
.withYearlySchedule(
new YearlyRetentionSchedule().withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY)
.withMonthsOfYear(Arrays.asList(MonthOfYear.JANUARY))
.withRetentionScheduleWeekly(
new WeeklyRetentionFormat().withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.FIRST)))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2021-09-29T08:00:00.000Z")))
.withRetentionDuration(
new RetentionDuration().withCount(10).withDurationType(RetentionDurationType.YEARS))))
.withTimeZone("UTC"))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.recoveryservicesbackup import RecoveryServicesBackupClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-recoveryservicesbackup
# USAGE
python protection_policies_create_or_update_daily.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 = RecoveryServicesBackupClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.protection_policies.create_or_update(
vault_name="swaggertestvault",
resource_group_name="SwaggerTestRg",
policy_name="dailyPolicy2",
parameters={
"properties": {
"backupManagementType": "AzureStorage",
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {"count": 5, "durationType": "Days"},
"retentionTimes": ["2021-09-29T08:00:00.000Z"],
},
"monthlySchedule": {
"retentionDuration": {"count": 60, "durationType": "Months"},
"retentionScheduleDaily": None,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {"daysOfTheWeek": ["Sunday"], "weeksOfTheMonth": ["First"]},
"retentionTimes": ["2021-09-29T08:00:00.000Z"],
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": ["Sunday"],
"retentionDuration": {"count": 12, "durationType": "Weeks"},
"retentionTimes": ["2021-09-29T08:00:00.000Z"],
},
"yearlySchedule": {
"monthsOfYear": ["January"],
"retentionDuration": {"count": 10, "durationType": "Years"},
"retentionScheduleDaily": None,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {"daysOfTheWeek": ["Sunday"], "weeksOfTheMonth": ["First"]},
"retentionTimes": ["2021-09-29T08:00:00.000Z"],
},
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": ["2021-09-29T08:00:00.000Z"],
},
"timeZone": "UTC",
"workLoadType": "AzureFileShare",
}
},
)
print(response)
# x-ms-original-file: 2026-07-01/AzureStorage/ProtectionPolicies_CreateOrUpdate_Daily.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 armrecoveryservicesbackup_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/recoveryservices/armrecoveryservicesbackup/v5"
)
// Generated from example definition: 2026-07-01/AzureStorage/ProtectionPolicies_CreateOrUpdate_Daily.json
func ExampleProtectionPoliciesClient_CreateOrUpdate_createOrUpdateDailyAzureStorageProtectionPolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armrecoveryservicesbackup.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewProtectionPoliciesClient().CreateOrUpdate(ctx, "swaggertestvault", "SwaggerTestRg", "dailyPolicy2", armrecoveryservicesbackup.ProtectionPolicyResource{
Properties: &armrecoveryservicesbackup.AzureFileShareProtectionPolicy{
BackupManagementType: to.Ptr("AzureStorage"),
RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](5),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2021, time.September, 29, 8, 0, 0, 0, time.UTC)),
},
},
MonthlySchedule: &armrecoveryservicesbackup.MonthlyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](60),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeMonths),
},
RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
},
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2021, time.September, 29, 8, 0, 0, 0, time.UTC)),
},
},
RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
WeeklySchedule: &armrecoveryservicesbackup.WeeklyRetentionSchedule{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](12),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeWeeks),
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2021, time.September, 29, 8, 0, 0, 0, time.UTC)),
},
},
YearlySchedule: &armrecoveryservicesbackup.YearlyRetentionSchedule{
MonthsOfYear: []*armrecoveryservicesbackup.MonthOfYear{
to.Ptr(armrecoveryservicesbackup.MonthOfYearJanuary),
},
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](10),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeYears),
},
RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
},
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2021, time.September, 29, 8, 0, 0, 0, time.UTC)),
},
},
},
SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeDaily),
ScheduleRunTimes: []*time.Time{
to.Ptr(time.Date(2021, time.September, 29, 8, 0, 0, 0, time.UTC)),
},
},
TimeZone: to.Ptr("UTC"),
WorkLoadType: to.Ptr(armrecoveryservicesbackup.WorkloadTypeAzureFileShare),
},
}, nil)
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 = armrecoveryservicesbackup.ProtectionPoliciesClientCreateOrUpdateResponse{
// ProtectionPolicyResource: armrecoveryservicesbackup.ProtectionPolicyResource{
// Name: to.Ptr("dailyPolicy2"),
// Type: to.Ptr("Microsoft.RecoveryServices/vaults/backupPolicies"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/dailyPolicy2"),
// Properties: &armrecoveryservicesbackup.AzureFileShareProtectionPolicy{
// BackupManagementType: to.Ptr("AzureStorage"),
// ProtectedItemsCount: to.Ptr[int32](0),
// RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
// DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](5),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.September, 29, 8, 0, 0, 0, time.UTC)),
// },
// },
// MonthlySchedule: &armrecoveryservicesbackup.MonthlyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](60),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeMonths),
// },
// RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
// RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
// },
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.September, 29, 8, 0, 0, 0, time.UTC)),
// },
// },
// RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
// WeeklySchedule: &armrecoveryservicesbackup.WeeklyRetentionSchedule{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](12),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeWeeks),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.September, 29, 8, 0, 0, 0, time.UTC)),
// },
// },
// YearlySchedule: &armrecoveryservicesbackup.YearlyRetentionSchedule{
// MonthsOfYear: []*armrecoveryservicesbackup.MonthOfYear{
// to.Ptr(armrecoveryservicesbackup.MonthOfYearJanuary),
// },
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](10),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeYears),
// },
// RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
// RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
// },
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.September, 29, 8, 0, 0, 0, time.UTC)),
// },
// },
// },
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
// ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeDaily),
// ScheduleRunTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.September, 29, 8, 0, 0, 0, time.UTC)),
// },
// ScheduleWeeklyFrequency: to.Ptr[int32](0),
// },
// TimeZone: to.Ptr("UTC"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { RecoveryServicesBackupClient } = require("@azure/arm-recoveryservicesbackup");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
*
* @summary creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
* x-ms-original-file: 2026-07-01/AzureStorage/ProtectionPolicies_CreateOrUpdate_Daily.json
*/
async function createOrUpdateDailyAzureStorageProtectionPolicy() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
"swaggertestvault",
"SwaggerTestRg",
"dailyPolicy2",
{
properties: {
backupManagementType: "AzureStorage",
retentionPolicy: {
dailySchedule: {
retentionDuration: { count: 5, durationType: "Days" },
retentionTimes: [new Date("2021-09-29T08:00:00.000Z")],
},
monthlySchedule: {
retentionDuration: { count: 60, durationType: "Months" },
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: { daysOfTheWeek: ["Sunday"], weeksOfTheMonth: ["First"] },
retentionTimes: [new Date("2021-09-29T08:00:00.000Z")],
},
retentionPolicyType: "LongTermRetentionPolicy",
weeklySchedule: {
daysOfTheWeek: ["Sunday"],
retentionDuration: { count: 12, durationType: "Weeks" },
retentionTimes: [new Date("2021-09-29T08:00:00.000Z")],
},
yearlySchedule: {
monthsOfYear: ["January"],
retentionDuration: { count: 10, durationType: "Years" },
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: { daysOfTheWeek: ["Sunday"], weeksOfTheMonth: ["First"] },
retentionTimes: [new Date("2021-09-29T08:00:00.000Z")],
},
},
schedulePolicy: {
schedulePolicyType: "SimpleSchedulePolicy",
scheduleRunFrequency: "Daily",
scheduleRunTimes: [new Date("2021-09-29T08:00:00.000Z")],
},
timeZone: "UTC",
workLoadType: "AzureFileShare",
},
},
);
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
Beispiel für eine Antwort
{
"name": "dailyPolicy2",
"type": "Microsoft.RecoveryServices/vaults/backupPolicies",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/dailyPolicy2",
"properties": {
"backupManagementType": "AzureStorage",
"protectedItemsCount": 0,
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {
"count": 5,
"durationType": "Days"
},
"retentionTimes": [
"2021-09-29T08:00:00Z"
]
},
"monthlySchedule": {
"retentionDuration": {
"count": 60,
"durationType": "Months"
},
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-09-29T08:00:00Z"
]
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
},
"retentionTimes": [
"2021-09-29T08:00:00Z"
]
},
"yearlySchedule": {
"monthsOfYear": [
"January"
],
"retentionDuration": {
"count": 10,
"durationType": "Years"
},
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-09-29T08:00:00Z"
]
}
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": [
"2021-09-29T08:00:00Z"
],
"scheduleWeeklyFrequency": 0
},
"timeZone": "UTC"
}
}
Azure-AsyncOperation: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/dailyPolicy2/operations/00000000-0000-0000-0000-000000000000?api-version=2016-06-01
Location: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/dailyPolicy2/operationResults/00000000-0000-0000-0000-000000000000?api-version=2016-06-01
Retry-After: 60
Create or Update Enhanced Azure Vm Protection Policy with daily backup
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/v2-daily-sample?api-version=2026-07-01
{
"properties": {
"backupManagementType": "AzureIaasVM",
"instantRpRetentionRangeInDays": 30,
"policyType": "V2",
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {
"count": 180,
"durationType": "Days"
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
},
"monthlySchedule": {
"retentionDuration": {
"count": 60,
"durationType": "Months"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
},
"yearlySchedule": {
"monthsOfYear": [
"January"
],
"retentionDuration": {
"count": 10,
"durationType": "Years"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
}
},
"schedulePolicy": {
"dailySchedule": {
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
]
},
"schedulePolicyType": "SimpleSchedulePolicyV2",
"scheduleRunFrequency": "Daily"
},
"snapshotConsistencyType": "OnlyCrashConsistent",
"timeZone": "India Standard Time"
}
}
import com.azure.resourcemanager.recoveryservicesbackup.models.AzureIaaSvmProtectionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.DailyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.DailySchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.DayOfWeek;
import com.azure.resourcemanager.recoveryservicesbackup.models.IaasVMSnapshotConsistencyType;
import com.azure.resourcemanager.recoveryservicesbackup.models.IaasvmPolicyType;
import com.azure.resourcemanager.recoveryservicesbackup.models.LongTermRetentionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.MonthOfYear;
import com.azure.resourcemanager.recoveryservicesbackup.models.MonthlyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDuration;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDurationType;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionScheduleFormat;
import com.azure.resourcemanager.recoveryservicesbackup.models.ScheduleRunType;
import com.azure.resourcemanager.recoveryservicesbackup.models.SimpleSchedulePolicyV2;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeekOfMonth;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionFormat;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.YearlyRetentionSchedule;
import java.time.OffsetDateTime;
import java.util.Arrays;
/**
* Samples for ProtectionPolicies CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/AzureIaasVm/V2Policy/IaaS_v2_daily.json
*/
/**
* Sample code: Create or Update Enhanced Azure Vm Protection Policy with daily backup.
*
* @param manager Entry point to RecoveryServicesBackupManager.
*/
public static void createOrUpdateEnhancedAzureVmProtectionPolicyWithDailyBackup(
com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager manager) {
manager
.protectionPolicies().define("v2-daily-sample").withExistingVault("NetSDKTestRsVault",
"SwaggerTestRg")
.withProperties(
new AzureIaaSvmProtectionPolicy()
.withSchedulePolicy(new SimpleSchedulePolicyV2().withScheduleRunFrequency(ScheduleRunType.DAILY)
.withDailySchedule(new DailySchedule()
.withScheduleRunTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z")))))
.withRetentionPolicy(
new LongTermRetentionPolicy()
.withDailySchedule(new DailyRetentionSchedule()
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2021-12-17T08:00:00+00:00")))
.withRetentionDuration(new RetentionDuration().withCount(180)
.withDurationType(RetentionDurationType.DAYS)))
.withWeeklySchedule(new WeeklyRetentionSchedule()
.withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2021-12-17T08:00:00+00:00")))
.withRetentionDuration(new RetentionDuration().withCount(12)
.withDurationType(RetentionDurationType.WEEKS)))
.withMonthlySchedule(new MonthlyRetentionSchedule()
.withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY)
.withRetentionScheduleWeekly(
new WeeklyRetentionFormat().withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.FIRST)))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2021-12-17T08:00:00+00:00")))
.withRetentionDuration(new RetentionDuration().withCount(60)
.withDurationType(RetentionDurationType.MONTHS)))
.withYearlySchedule(new YearlyRetentionSchedule()
.withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY)
.withMonthsOfYear(Arrays.asList(MonthOfYear.JANUARY))
.withRetentionScheduleWeekly(
new WeeklyRetentionFormat().withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.FIRST)))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2021-12-17T08:00:00+00:00")))
.withRetentionDuration(new RetentionDuration().withCount(10)
.withDurationType(RetentionDurationType.YEARS))))
.withInstantRpRetentionRangeInDays(30).withTimeZone("India Standard Time")
.withPolicyType(IaasvmPolicyType.V2)
.withSnapshotConsistencyType(IaasVMSnapshotConsistencyType.ONLY_CRASH_CONSISTENT))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.recoveryservicesbackup import RecoveryServicesBackupClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-recoveryservicesbackup
# USAGE
python iaa_s_v2_daily.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 = RecoveryServicesBackupClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.protection_policies.create_or_update(
vault_name="NetSDKTestRsVault",
resource_group_name="SwaggerTestRg",
policy_name="v2-daily-sample",
parameters={
"properties": {
"backupManagementType": "AzureIaasVM",
"instantRpRetentionRangeInDays": 30,
"policyType": "V2",
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {"count": 180, "durationType": "Days"},
"retentionTimes": ["2021-12-17T08:00:00+00:00"],
},
"monthlySchedule": {
"retentionDuration": {"count": 60, "durationType": "Months"},
"retentionScheduleDaily": None,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {"daysOfTheWeek": ["Sunday"], "weeksOfTheMonth": ["First"]},
"retentionTimes": ["2021-12-17T08:00:00+00:00"],
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": ["Sunday"],
"retentionDuration": {"count": 12, "durationType": "Weeks"},
"retentionTimes": ["2021-12-17T08:00:00+00:00"],
},
"yearlySchedule": {
"monthsOfYear": ["January"],
"retentionDuration": {"count": 10, "durationType": "Years"},
"retentionScheduleDaily": None,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {"daysOfTheWeek": ["Sunday"], "weeksOfTheMonth": ["First"]},
"retentionTimes": ["2021-12-17T08:00:00+00:00"],
},
},
"schedulePolicy": {
"dailySchedule": {"scheduleRunTimes": ["2018-01-24T10:00:00Z"]},
"schedulePolicyType": "SimpleSchedulePolicyV2",
"scheduleRunFrequency": "Daily",
},
"snapshotConsistencyType": "OnlyCrashConsistent",
"timeZone": "India Standard Time",
}
},
)
print(response)
# x-ms-original-file: 2026-07-01/AzureIaasVm/V2Policy/IaaS_v2_daily.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 armrecoveryservicesbackup_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/recoveryservices/armrecoveryservicesbackup/v5"
)
// Generated from example definition: 2026-07-01/AzureIaasVm/V2Policy/IaaS_v2_daily.json
func ExampleProtectionPoliciesClient_CreateOrUpdate_createOrUpdateEnhancedAzureVMProtectionPolicyWithDailyBackup() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armrecoveryservicesbackup.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewProtectionPoliciesClient().CreateOrUpdate(ctx, "NetSDKTestRsVault", "SwaggerTestRg", "v2-daily-sample", armrecoveryservicesbackup.ProtectionPolicyResource{
Properties: &armrecoveryservicesbackup.AzureIaaSVMProtectionPolicy{
BackupManagementType: to.Ptr("AzureIaasVM"),
InstantRpRetentionRangeInDays: to.Ptr[int32](30),
PolicyType: to.Ptr(armrecoveryservicesbackup.IAASVMPolicyTypeV2),
RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](180),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
},
},
MonthlySchedule: &armrecoveryservicesbackup.MonthlyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](60),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeMonths),
},
RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
},
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
},
},
RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
WeeklySchedule: &armrecoveryservicesbackup.WeeklyRetentionSchedule{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](12),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeWeeks),
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
},
},
YearlySchedule: &armrecoveryservicesbackup.YearlyRetentionSchedule{
MonthsOfYear: []*armrecoveryservicesbackup.MonthOfYear{
to.Ptr(armrecoveryservicesbackup.MonthOfYearJanuary),
},
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](10),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeYears),
},
RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
},
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
},
},
},
SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicyV2{
DailySchedule: &armrecoveryservicesbackup.DailySchedule{
ScheduleRunTimes: []*time.Time{
to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
},
},
SchedulePolicyType: to.Ptr("SimpleSchedulePolicyV2"),
ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeDaily),
},
SnapshotConsistencyType: to.Ptr(armrecoveryservicesbackup.IaasVMSnapshotConsistencyTypeOnlyCrashConsistent),
TimeZone: to.Ptr("India Standard Time"),
},
}, nil)
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 = armrecoveryservicesbackup.ProtectionPoliciesClientCreateOrUpdateResponse{
// ProtectionPolicyResource: armrecoveryservicesbackup.ProtectionPolicyResource{
// Name: to.Ptr("v2-daily-sample"),
// Type: to.Ptr("Microsoft.RecoveryServices/vaults/backupPolicies"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/v2-daily-sample"),
// Properties: &armrecoveryservicesbackup.AzureIaaSVMProtectionPolicy{
// BackupManagementType: to.Ptr("AzureIaasVM"),
// InstantRpRetentionRangeInDays: to.Ptr[int32](30),
// PolicyType: to.Ptr(armrecoveryservicesbackup.IAASVMPolicyTypeV2),
// ProtectedItemsCount: to.Ptr[int32](0),
// RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
// DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](180),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
// },
// },
// MonthlySchedule: &armrecoveryservicesbackup.MonthlyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](60),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeMonths),
// },
// RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
// RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
// },
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
// },
// },
// RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
// WeeklySchedule: &armrecoveryservicesbackup.WeeklyRetentionSchedule{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](12),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeWeeks),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
// },
// },
// YearlySchedule: &armrecoveryservicesbackup.YearlyRetentionSchedule{
// MonthsOfYear: []*armrecoveryservicesbackup.MonthOfYear{
// to.Ptr(armrecoveryservicesbackup.MonthOfYearJanuary),
// },
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](10),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeYears),
// },
// RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
// RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
// },
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
// },
// },
// },
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicyV2{
// DailySchedule: &armrecoveryservicesbackup.DailySchedule{
// ScheduleRunTimes: []*time.Time{
// to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
// },
// },
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicyV2"),
// ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeDaily),
// },
// SnapshotConsistencyType: to.Ptr(armrecoveryservicesbackup.IaasVMSnapshotConsistencyTypeOnlyCrashConsistent),
// TimeZone: to.Ptr("India Standard Time"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { RecoveryServicesBackupClient } = require("@azure/arm-recoveryservicesbackup");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
*
* @summary creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
* x-ms-original-file: 2026-07-01/AzureIaasVm/V2Policy/IaaS_v2_daily.json
*/
async function createOrUpdateEnhancedAzureVmProtectionPolicyWithDailyBackup() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
"NetSDKTestRsVault",
"SwaggerTestRg",
"v2-daily-sample",
{
properties: {
backupManagementType: "AzureIaasVM",
instantRpRetentionRangeInDays: 30,
policyType: "V2",
retentionPolicy: {
dailySchedule: {
retentionDuration: { count: 180, durationType: "Days" },
retentionTimes: [new Date("2021-12-17T08:00:00+00:00")],
},
monthlySchedule: {
retentionDuration: { count: 60, durationType: "Months" },
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: { daysOfTheWeek: ["Sunday"], weeksOfTheMonth: ["First"] },
retentionTimes: [new Date("2021-12-17T08:00:00+00:00")],
},
retentionPolicyType: "LongTermRetentionPolicy",
weeklySchedule: {
daysOfTheWeek: ["Sunday"],
retentionDuration: { count: 12, durationType: "Weeks" },
retentionTimes: [new Date("2021-12-17T08:00:00+00:00")],
},
yearlySchedule: {
monthsOfYear: ["January"],
retentionDuration: { count: 10, durationType: "Years" },
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: { daysOfTheWeek: ["Sunday"], weeksOfTheMonth: ["First"] },
retentionTimes: [new Date("2021-12-17T08:00:00+00:00")],
},
},
schedulePolicy: {
dailySchedule: { scheduleRunTimes: [new Date("2018-01-24T10:00:00Z")] },
schedulePolicyType: "SimpleSchedulePolicyV2",
scheduleRunFrequency: "Daily",
},
snapshotConsistencyType: "OnlyCrashConsistent",
timeZone: "India Standard Time",
},
},
);
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
Beispiel für eine Antwort
{
"name": "v2-daily-sample",
"type": "Microsoft.RecoveryServices/vaults/backupPolicies",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/v2-daily-sample",
"properties": {
"backupManagementType": "AzureIaasVM",
"instantRpRetentionRangeInDays": 30,
"policyType": "V2",
"protectedItemsCount": 0,
"resourceGuardOperationRequests": null,
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {
"count": 180,
"durationType": "Days"
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
},
"monthlySchedule": {
"retentionDuration": {
"count": 60,
"durationType": "Months"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
},
"yearlySchedule": {
"monthsOfYear": [
"January"
],
"retentionDuration": {
"count": 10,
"durationType": "Years"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
}
},
"schedulePolicy": {
"dailySchedule": {
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
]
},
"schedulePolicyType": "SimpleSchedulePolicyV2",
"scheduleRunFrequency": "Daily"
},
"snapshotConsistencyType": "OnlyCrashConsistent",
"timeZone": "India Standard Time"
}
}
Azure-AsyncOperation: https://management.azure.com/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/v2-daily-sample/operations/00000000-0000-0000-0000-000000000000?api-version=2020-06-01
Location: https://management.azure.com/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/v2-daily-sample/operationResults/00000000-0000-0000-0000-000000000000?api-version=2020-06-01
Retry-After: 60
Create or Update Enhanced Azure Vm Protection Policy with Hourly backup
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/v2-daily-sample?api-version=2026-07-01
{
"properties": {
"backupManagementType": "AzureIaasVM",
"instantRpRetentionRangeInDays": 30,
"policyType": "V2",
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {
"count": 180,
"durationType": "Days"
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
},
"monthlySchedule": {
"retentionDuration": {
"count": 60,
"durationType": "Months"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
},
"yearlySchedule": {
"monthsOfYear": [
"January"
],
"retentionDuration": {
"count": 10,
"durationType": "Years"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
}
},
"schedulePolicy": {
"hourlySchedule": {
"interval": 4,
"scheduleWindowDuration": 16,
"scheduleWindowStartTime": "2021-12-17T08:00:00Z"
},
"schedulePolicyType": "SimpleSchedulePolicyV2",
"scheduleRunFrequency": "Hourly"
},
"snapshotConsistencyType": "OnlyCrashConsistent",
"timeZone": "India Standard Time"
}
}
import com.azure.resourcemanager.recoveryservicesbackup.models.AzureIaaSvmProtectionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.DailyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.DayOfWeek;
import com.azure.resourcemanager.recoveryservicesbackup.models.HourlySchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.IaasVMSnapshotConsistencyType;
import com.azure.resourcemanager.recoveryservicesbackup.models.IaasvmPolicyType;
import com.azure.resourcemanager.recoveryservicesbackup.models.LongTermRetentionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.MonthOfYear;
import com.azure.resourcemanager.recoveryservicesbackup.models.MonthlyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDuration;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDurationType;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionScheduleFormat;
import com.azure.resourcemanager.recoveryservicesbackup.models.ScheduleRunType;
import com.azure.resourcemanager.recoveryservicesbackup.models.SimpleSchedulePolicyV2;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeekOfMonth;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionFormat;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.YearlyRetentionSchedule;
import java.time.OffsetDateTime;
import java.util.Arrays;
/**
* Samples for ProtectionPolicies CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/AzureIaasVm/V2Policy/IaaS_v2_hourly.json
*/
/**
* Sample code: Create or Update Enhanced Azure Vm Protection Policy with Hourly backup.
*
* @param manager Entry point to RecoveryServicesBackupManager.
*/
public static void createOrUpdateEnhancedAzureVmProtectionPolicyWithHourlyBackup(
com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager manager) {
manager
.protectionPolicies().define(
"v2-daily-sample")
.withExistingVault("NetSDKTestRsVault",
"SwaggerTestRg")
.withProperties(
new AzureIaaSvmProtectionPolicy()
.withSchedulePolicy(new SimpleSchedulePolicyV2().withScheduleRunFrequency(ScheduleRunType.HOURLY)
.withHourlySchedule(new HourlySchedule().withInterval(4).withScheduleWindowStartTime(
OffsetDateTime.parse("2021-12-17T08:00:00Z")).withScheduleWindowDuration(16)))
.withRetentionPolicy(
new LongTermRetentionPolicy()
.withDailySchedule(new DailyRetentionSchedule()
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2021-12-17T08:00:00+00:00")))
.withRetentionDuration(new RetentionDuration().withCount(180)
.withDurationType(RetentionDurationType.DAYS)))
.withWeeklySchedule(new WeeklyRetentionSchedule()
.withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2021-12-17T08:00:00+00:00")))
.withRetentionDuration(new RetentionDuration().withCount(12).withDurationType(
RetentionDurationType.WEEKS)))
.withMonthlySchedule(new MonthlyRetentionSchedule()
.withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY)
.withRetentionScheduleWeekly(
new WeeklyRetentionFormat().withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.FIRST)))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2021-12-17T08:00:00+00:00")))
.withRetentionDuration(new RetentionDuration().withCount(60)
.withDurationType(RetentionDurationType.MONTHS)))
.withYearlySchedule(new YearlyRetentionSchedule()
.withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY)
.withMonthsOfYear(Arrays.asList(MonthOfYear.JANUARY))
.withRetentionScheduleWeekly(
new WeeklyRetentionFormat().withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.FIRST)))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2021-12-17T08:00:00+00:00")))
.withRetentionDuration(new RetentionDuration().withCount(10)
.withDurationType(RetentionDurationType.YEARS))))
.withInstantRpRetentionRangeInDays(30).withTimeZone("India Standard Time")
.withPolicyType(IaasvmPolicyType.V2)
.withSnapshotConsistencyType(IaasVMSnapshotConsistencyType.ONLY_CRASH_CONSISTENT))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.recoveryservicesbackup import RecoveryServicesBackupClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-recoveryservicesbackup
# USAGE
python iaa_s_v2_hourly.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 = RecoveryServicesBackupClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.protection_policies.create_or_update(
vault_name="NetSDKTestRsVault",
resource_group_name="SwaggerTestRg",
policy_name="v2-daily-sample",
parameters={
"properties": {
"backupManagementType": "AzureIaasVM",
"instantRpRetentionRangeInDays": 30,
"policyType": "V2",
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {"count": 180, "durationType": "Days"},
"retentionTimes": ["2021-12-17T08:00:00+00:00"],
},
"monthlySchedule": {
"retentionDuration": {"count": 60, "durationType": "Months"},
"retentionScheduleDaily": None,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {"daysOfTheWeek": ["Sunday"], "weeksOfTheMonth": ["First"]},
"retentionTimes": ["2021-12-17T08:00:00+00:00"],
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": ["Sunday"],
"retentionDuration": {"count": 12, "durationType": "Weeks"},
"retentionTimes": ["2021-12-17T08:00:00+00:00"],
},
"yearlySchedule": {
"monthsOfYear": ["January"],
"retentionDuration": {"count": 10, "durationType": "Years"},
"retentionScheduleDaily": None,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {"daysOfTheWeek": ["Sunday"], "weeksOfTheMonth": ["First"]},
"retentionTimes": ["2021-12-17T08:00:00+00:00"],
},
},
"schedulePolicy": {
"hourlySchedule": {
"interval": 4,
"scheduleWindowDuration": 16,
"scheduleWindowStartTime": "2021-12-17T08:00:00Z",
},
"schedulePolicyType": "SimpleSchedulePolicyV2",
"scheduleRunFrequency": "Hourly",
},
"snapshotConsistencyType": "OnlyCrashConsistent",
"timeZone": "India Standard Time",
}
},
)
print(response)
# x-ms-original-file: 2026-07-01/AzureIaasVm/V2Policy/IaaS_v2_hourly.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 armrecoveryservicesbackup_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/recoveryservices/armrecoveryservicesbackup/v5"
)
// Generated from example definition: 2026-07-01/AzureIaasVm/V2Policy/IaaS_v2_hourly.json
func ExampleProtectionPoliciesClient_CreateOrUpdate_createOrUpdateEnhancedAzureVMProtectionPolicyWithHourlyBackup() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armrecoveryservicesbackup.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewProtectionPoliciesClient().CreateOrUpdate(ctx, "NetSDKTestRsVault", "SwaggerTestRg", "v2-daily-sample", armrecoveryservicesbackup.ProtectionPolicyResource{
Properties: &armrecoveryservicesbackup.AzureIaaSVMProtectionPolicy{
BackupManagementType: to.Ptr("AzureIaasVM"),
InstantRpRetentionRangeInDays: to.Ptr[int32](30),
PolicyType: to.Ptr(armrecoveryservicesbackup.IAASVMPolicyTypeV2),
RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](180),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
},
},
MonthlySchedule: &armrecoveryservicesbackup.MonthlyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](60),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeMonths),
},
RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
},
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
},
},
RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
WeeklySchedule: &armrecoveryservicesbackup.WeeklyRetentionSchedule{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](12),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeWeeks),
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
},
},
YearlySchedule: &armrecoveryservicesbackup.YearlyRetentionSchedule{
MonthsOfYear: []*armrecoveryservicesbackup.MonthOfYear{
to.Ptr(armrecoveryservicesbackup.MonthOfYearJanuary),
},
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](10),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeYears),
},
RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
},
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
},
},
},
SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicyV2{
HourlySchedule: &armrecoveryservicesbackup.HourlySchedule{
Interval: to.Ptr[int32](4),
ScheduleWindowDuration: to.Ptr[int32](16),
ScheduleWindowStartTime: to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
},
SchedulePolicyType: to.Ptr("SimpleSchedulePolicyV2"),
ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeHourly),
},
SnapshotConsistencyType: to.Ptr(armrecoveryservicesbackup.IaasVMSnapshotConsistencyTypeOnlyCrashConsistent),
TimeZone: to.Ptr("India Standard Time"),
},
}, nil)
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 = armrecoveryservicesbackup.ProtectionPoliciesClientCreateOrUpdateResponse{
// ProtectionPolicyResource: armrecoveryservicesbackup.ProtectionPolicyResource{
// Name: to.Ptr("v2-daily-sample"),
// Type: to.Ptr("Microsoft.RecoveryServices/vaults/backupPolicies"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/v2-daily-sample"),
// Properties: &armrecoveryservicesbackup.AzureIaaSVMProtectionPolicy{
// BackupManagementType: to.Ptr("AzureIaasVM"),
// InstantRpRetentionRangeInDays: to.Ptr[int32](30),
// PolicyType: to.Ptr(armrecoveryservicesbackup.IAASVMPolicyTypeV2),
// ProtectedItemsCount: to.Ptr[int32](0),
// RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
// DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](180),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
// },
// },
// MonthlySchedule: &armrecoveryservicesbackup.MonthlyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](60),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeMonths),
// },
// RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
// RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
// },
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
// },
// },
// RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
// WeeklySchedule: &armrecoveryservicesbackup.WeeklyRetentionSchedule{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](12),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeWeeks),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
// },
// },
// YearlySchedule: &armrecoveryservicesbackup.YearlyRetentionSchedule{
// MonthsOfYear: []*armrecoveryservicesbackup.MonthOfYear{
// to.Ptr(armrecoveryservicesbackup.MonthOfYearJanuary),
// },
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](10),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeYears),
// },
// RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
// RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
// },
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
// },
// },
// },
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicyV2{
// HourlySchedule: &armrecoveryservicesbackup.HourlySchedule{
// Interval: to.Ptr[int32](4),
// ScheduleWindowDuration: to.Ptr[int32](16),
// ScheduleWindowStartTime: to.Ptr(time.Date(2021, time.December, 17, 8, 0, 0, 0, time.UTC)),
// },
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicyV2"),
// ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeHourly),
// },
// SnapshotConsistencyType: to.Ptr(armrecoveryservicesbackup.IaasVMSnapshotConsistencyTypeOnlyCrashConsistent),
// TimeZone: to.Ptr("India Standard Time"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { RecoveryServicesBackupClient } = require("@azure/arm-recoveryservicesbackup");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
*
* @summary creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
* x-ms-original-file: 2026-07-01/AzureIaasVm/V2Policy/IaaS_v2_hourly.json
*/
async function createOrUpdateEnhancedAzureVmProtectionPolicyWithHourlyBackup() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
"NetSDKTestRsVault",
"SwaggerTestRg",
"v2-daily-sample",
{
properties: {
backupManagementType: "AzureIaasVM",
instantRpRetentionRangeInDays: 30,
policyType: "V2",
retentionPolicy: {
dailySchedule: {
retentionDuration: { count: 180, durationType: "Days" },
retentionTimes: [new Date("2021-12-17T08:00:00+00:00")],
},
monthlySchedule: {
retentionDuration: { count: 60, durationType: "Months" },
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: { daysOfTheWeek: ["Sunday"], weeksOfTheMonth: ["First"] },
retentionTimes: [new Date("2021-12-17T08:00:00+00:00")],
},
retentionPolicyType: "LongTermRetentionPolicy",
weeklySchedule: {
daysOfTheWeek: ["Sunday"],
retentionDuration: { count: 12, durationType: "Weeks" },
retentionTimes: [new Date("2021-12-17T08:00:00+00:00")],
},
yearlySchedule: {
monthsOfYear: ["January"],
retentionDuration: { count: 10, durationType: "Years" },
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: { daysOfTheWeek: ["Sunday"], weeksOfTheMonth: ["First"] },
retentionTimes: [new Date("2021-12-17T08:00:00+00:00")],
},
},
schedulePolicy: {
hourlySchedule: {
interval: 4,
scheduleWindowDuration: 16,
scheduleWindowStartTime: new Date("2021-12-17T08:00:00Z"),
},
schedulePolicyType: "SimpleSchedulePolicyV2",
scheduleRunFrequency: "Hourly",
},
snapshotConsistencyType: "OnlyCrashConsistent",
timeZone: "India Standard Time",
},
},
);
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
Beispiel für eine Antwort
{
"name": "v2-daily-sample",
"type": "Microsoft.RecoveryServices/vaults/backupPolicies",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/v2-daily-sample",
"properties": {
"backupManagementType": "AzureIaasVM",
"instantRpRetentionRangeInDays": 30,
"policyType": "V2",
"protectedItemsCount": 0,
"resourceGuardOperationRequests": null,
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {
"count": 180,
"durationType": "Days"
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
},
"monthlySchedule": {
"retentionDuration": {
"count": 60,
"durationType": "Months"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
},
"yearlySchedule": {
"monthsOfYear": [
"January"
],
"retentionDuration": {
"count": 10,
"durationType": "Years"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
}
},
"schedulePolicy": {
"hourlySchedule": {
"interval": 4,
"scheduleWindowDuration": 16,
"scheduleWindowStartTime": "2021-12-17T08:00:00Z"
},
"schedulePolicyType": "SimpleSchedulePolicyV2",
"scheduleRunFrequency": "Hourly"
},
"snapshotConsistencyType": "OnlyCrashConsistent",
"timeZone": "India Standard Time"
}
}
Azure-AsyncOperation: https://management.azure.com/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/v2-daily-sample/operations/00000000-0000-0000-0000-000000000000?api-version=2020-06-01
Location: https://management.azure.com/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/v2-daily-sample/operationResults/00000000-0000-0000-0000-000000000000?api-version=2020-06-01
Retry-After: 60
Create or Update Full Azure Vm Protection Policy
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1?api-version=2026-07-01
{
"properties": {
"backupManagementType": "AzureIaasVM",
"retentionPolicy": {
"monthlySchedule": {
"retentionDuration": {
"count": 2,
"durationType": "Months"
},
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Wednesday",
"Thursday"
],
"weeksOfTheMonth": [
"First",
"Third"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
]
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Monday",
"Wednesday",
"Thursday"
],
"retentionDuration": {
"count": 1,
"durationType": "Weeks"
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
]
},
"yearlySchedule": {
"monthsOfYear": [
"February",
"November"
],
"retentionDuration": {
"count": 4,
"durationType": "Years"
},
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Monday",
"Thursday"
],
"weeksOfTheMonth": [
"Fourth"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
]
}
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunDays": [
"Monday",
"Wednesday",
"Thursday"
],
"scheduleRunFrequency": "Weekly",
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
]
},
"timeZone": "Pacific Standard Time"
}
}
import com.azure.resourcemanager.recoveryservicesbackup.models.AzureIaaSvmProtectionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.DayOfWeek;
import com.azure.resourcemanager.recoveryservicesbackup.models.LongTermRetentionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.MonthOfYear;
import com.azure.resourcemanager.recoveryservicesbackup.models.MonthlyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDuration;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDurationType;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionScheduleFormat;
import com.azure.resourcemanager.recoveryservicesbackup.models.ScheduleRunType;
import com.azure.resourcemanager.recoveryservicesbackup.models.SimpleSchedulePolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeekOfMonth;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionFormat;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.YearlyRetentionSchedule;
import java.time.OffsetDateTime;
import java.util.Arrays;
/**
* Samples for ProtectionPolicies CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Complex.json
*/
/**
* Sample code: Create or Update Full Azure Vm Protection Policy.
*
* @param manager Entry point to RecoveryServicesBackupManager.
*/
public static void createOrUpdateFullAzureVmProtectionPolicy(
com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager manager) {
manager.protectionPolicies().define("testPolicy1").withExistingVault("NetSDKTestRsVault", "SwaggerTestRg")
.withProperties(
new AzureIaaSvmProtectionPolicy()
.withSchedulePolicy(new SimpleSchedulePolicy().withScheduleRunFrequency(ScheduleRunType.WEEKLY)
.withScheduleRunDays(Arrays.asList(DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY,
DayOfWeek.THURSDAY))
.withScheduleRunTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z"))))
.withRetentionPolicy(
new LongTermRetentionPolicy()
.withWeeklySchedule(
new WeeklyRetentionSchedule()
.withDaysOfTheWeek(
Arrays.asList(DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z")))
.withRetentionDuration(new RetentionDuration().withCount(1)
.withDurationType(RetentionDurationType.WEEKS)))
.withMonthlySchedule(
new MonthlyRetentionSchedule()
.withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY)
.withRetentionScheduleWeekly(new WeeklyRetentionFormat()
.withDaysOfTheWeek(Arrays.asList(DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY))
.withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.FIRST, WeekOfMonth.THIRD)))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z")))
.withRetentionDuration(new RetentionDuration().withCount(2)
.withDurationType(RetentionDurationType.MONTHS)))
.withYearlySchedule(
new YearlyRetentionSchedule()
.withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY)
.withMonthsOfYear(Arrays.asList(MonthOfYear.FEBRUARY, MonthOfYear.NOVEMBER))
.withRetentionScheduleWeekly(new WeeklyRetentionFormat()
.withDaysOfTheWeek(Arrays.asList(DayOfWeek.MONDAY, DayOfWeek.THURSDAY))
.withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.FOURTH)))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z")))
.withRetentionDuration(new RetentionDuration().withCount(4)
.withDurationType(RetentionDurationType.YEARS))))
.withTimeZone("Pacific Standard Time"))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armrecoveryservicesbackup_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/recoveryservices/armrecoveryservicesbackup/v5"
)
// Generated from example definition: 2026-07-01/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Complex.json
func ExampleProtectionPoliciesClient_CreateOrUpdate_createOrUpdateFullAzureVMProtectionPolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armrecoveryservicesbackup.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewProtectionPoliciesClient().CreateOrUpdate(ctx, "NetSDKTestRsVault", "SwaggerTestRg", "testPolicy1", armrecoveryservicesbackup.ProtectionPolicyResource{
Properties: &armrecoveryservicesbackup.AzureIaaSVMProtectionPolicy{
BackupManagementType: to.Ptr("AzureIaasVM"),
RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
MonthlySchedule: &armrecoveryservicesbackup.MonthlyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](2),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeMonths),
},
RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekWednesday),
to.Ptr(armrecoveryservicesbackup.DayOfWeekThursday),
},
WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
to.Ptr(armrecoveryservicesbackup.WeekOfMonthThird),
},
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
},
},
RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
WeeklySchedule: &armrecoveryservicesbackup.WeeklyRetentionSchedule{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekMonday),
to.Ptr(armrecoveryservicesbackup.DayOfWeekWednesday),
to.Ptr(armrecoveryservicesbackup.DayOfWeekThursday),
},
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](1),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeWeeks),
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
},
},
YearlySchedule: &armrecoveryservicesbackup.YearlyRetentionSchedule{
MonthsOfYear: []*armrecoveryservicesbackup.MonthOfYear{
to.Ptr(armrecoveryservicesbackup.MonthOfYearFebruary),
to.Ptr(armrecoveryservicesbackup.MonthOfYearNovember),
},
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](4),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeYears),
},
RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekMonday),
to.Ptr(armrecoveryservicesbackup.DayOfWeekThursday),
},
WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
to.Ptr(armrecoveryservicesbackup.WeekOfMonthFourth),
},
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
},
},
},
SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
ScheduleRunDays: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekMonday),
to.Ptr(armrecoveryservicesbackup.DayOfWeekWednesday),
to.Ptr(armrecoveryservicesbackup.DayOfWeekThursday),
},
ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeWeekly),
ScheduleRunTimes: []*time.Time{
to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
},
},
TimeZone: to.Ptr("Pacific Standard Time"),
},
}, nil)
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 = armrecoveryservicesbackup.ProtectionPoliciesClientCreateOrUpdateResponse{
// ProtectionPolicyResource: armrecoveryservicesbackup.ProtectionPolicyResource{
// Name: to.Ptr("testPolicy1"),
// Type: to.Ptr("Microsoft.RecoveryServices/vaults/backupPolicies"),
// ID: to.Ptr("/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1"),
// Properties: &armrecoveryservicesbackup.AzureIaaSVMProtectionPolicy{
// BackupManagementType: to.Ptr("AzureIaasVM"),
// ProtectedItemsCount: to.Ptr[int32](0),
// RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
// MonthlySchedule: &armrecoveryservicesbackup.MonthlyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](2),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeMonths),
// },
// RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
// RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekWednesday),
// to.Ptr(armrecoveryservicesbackup.DayOfWeekThursday),
// },
// WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthThird),
// },
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
// },
// },
// RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
// WeeklySchedule: &armrecoveryservicesbackup.WeeklyRetentionSchedule{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekMonday),
// to.Ptr(armrecoveryservicesbackup.DayOfWeekWednesday),
// to.Ptr(armrecoveryservicesbackup.DayOfWeekThursday),
// },
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](1),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeWeeks),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
// },
// },
// YearlySchedule: &armrecoveryservicesbackup.YearlyRetentionSchedule{
// MonthsOfYear: []*armrecoveryservicesbackup.MonthOfYear{
// to.Ptr(armrecoveryservicesbackup.MonthOfYearFebruary),
// to.Ptr(armrecoveryservicesbackup.MonthOfYearNovember),
// },
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](4),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeYears),
// },
// RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
// RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekMonday),
// to.Ptr(armrecoveryservicesbackup.DayOfWeekThursday),
// },
// WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthFourth),
// },
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
// },
// },
// },
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
// ScheduleRunDays: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekMonday),
// to.Ptr(armrecoveryservicesbackup.DayOfWeekWednesday),
// to.Ptr(armrecoveryservicesbackup.DayOfWeekThursday),
// },
// ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeWeekly),
// ScheduleRunTimes: []*time.Time{
// to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
// },
// ScheduleWeeklyFrequency: to.Ptr[int32](0),
// },
// TimeZone: to.Ptr("Pacific Standard Time"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { RecoveryServicesBackupClient } = require("@azure/arm-recoveryservicesbackup");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
*
* @summary creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
* x-ms-original-file: 2026-07-01/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Complex.json
*/
async function createOrUpdateFullAzureVmProtectionPolicy() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
"NetSDKTestRsVault",
"SwaggerTestRg",
"testPolicy1",
{
properties: {
backupManagementType: "AzureIaasVM",
retentionPolicy: {
monthlySchedule: {
retentionDuration: { count: 2, durationType: "Months" },
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: {
daysOfTheWeek: ["Wednesday", "Thursday"],
weeksOfTheMonth: ["First", "Third"],
},
retentionTimes: [new Date("2018-01-24T10:00:00Z")],
},
retentionPolicyType: "LongTermRetentionPolicy",
weeklySchedule: {
daysOfTheWeek: ["Monday", "Wednesday", "Thursday"],
retentionDuration: { count: 1, durationType: "Weeks" },
retentionTimes: [new Date("2018-01-24T10:00:00Z")],
},
yearlySchedule: {
monthsOfYear: ["February", "November"],
retentionDuration: { count: 4, durationType: "Years" },
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: {
daysOfTheWeek: ["Monday", "Thursday"],
weeksOfTheMonth: ["Fourth"],
},
retentionTimes: [new Date("2018-01-24T10:00:00Z")],
},
},
schedulePolicy: {
schedulePolicyType: "SimpleSchedulePolicy",
scheduleRunDays: ["Monday", "Wednesday", "Thursday"],
scheduleRunFrequency: "Weekly",
scheduleRunTimes: [new Date("2018-01-24T10:00:00Z")],
},
timeZone: "Pacific Standard Time",
},
},
);
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
Beispiel für eine Antwort
{
"name": "testPolicy1",
"type": "Microsoft.RecoveryServices/vaults/backupPolicies",
"id": "/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1",
"properties": {
"backupManagementType": "AzureIaasVM",
"protectedItemsCount": 0,
"retentionPolicy": {
"monthlySchedule": {
"retentionDuration": {
"count": 2,
"durationType": "Months"
},
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Wednesday",
"Thursday"
],
"weeksOfTheMonth": [
"First",
"Third"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
]
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Monday",
"Wednesday",
"Thursday"
],
"retentionDuration": {
"count": 1,
"durationType": "Weeks"
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
]
},
"yearlySchedule": {
"monthsOfYear": [
"February",
"November"
],
"retentionDuration": {
"count": 4,
"durationType": "Years"
},
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Monday",
"Thursday"
],
"weeksOfTheMonth": [
"Fourth"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
]
}
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunDays": [
"Monday",
"Wednesday",
"Thursday"
],
"scheduleRunFrequency": "Weekly",
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
],
"scheduleWeeklyFrequency": 0
},
"timeZone": "Pacific Standard Time"
}
}
Azure-AsyncOperation: https://management.azure.com/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1/operations/00000000-0000-0000-0000-000000000000?api-version=2016-06-01
Location: https://management.azure.com/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1/operationResults/00000000-0000-0000-0000-000000000000?api-version=2016-06-01
Retry-After: 60
Create or Update Full Azure Workload Protection Policy
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1?api-version=2026-07-01
{
"properties": {
"backupManagementType": "AzureWorkload",
"settings": {
"issqlcompression": false,
"timeZone": "Pacific Standard Time"
},
"subProtectionPolicy": [
{
"policyType": "Full",
"retentionPolicy": {
"monthlySchedule": {
"retentionDuration": {
"count": 1,
"durationType": "Months"
},
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"Second"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
]
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday",
"Tuesday"
],
"retentionDuration": {
"count": 2,
"durationType": "Weeks"
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
]
},
"yearlySchedule": {
"monthsOfYear": [
"January",
"June",
"December"
],
"retentionDuration": {
"count": 1,
"durationType": "Years"
},
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"Last"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
]
}
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunDays": [
"Sunday",
"Tuesday"
],
"scheduleRunFrequency": "Weekly",
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
]
}
},
{
"policyType": "Differential",
"retentionPolicy": {
"retentionDuration": {
"count": 8,
"durationType": "Days"
},
"retentionPolicyType": "SimpleRetentionPolicy"
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunDays": [
"Friday"
],
"scheduleRunFrequency": "Weekly",
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
]
}
},
{
"policyType": "Log",
"retentionPolicy": {
"retentionDuration": {
"count": 7,
"durationType": "Days"
},
"retentionPolicyType": "SimpleRetentionPolicy"
},
"schedulePolicy": {
"scheduleFrequencyInMins": 60,
"schedulePolicyType": "LogSchedulePolicy"
}
}
],
"workLoadType": "SQLDataBase"
}
}
import com.azure.resourcemanager.recoveryservicesbackup.models.AzureVmWorkloadProtectionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.DayOfWeek;
import com.azure.resourcemanager.recoveryservicesbackup.models.LogSchedulePolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.LongTermRetentionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.MonthOfYear;
import com.azure.resourcemanager.recoveryservicesbackup.models.MonthlyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.PolicyType;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDuration;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDurationType;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionScheduleFormat;
import com.azure.resourcemanager.recoveryservicesbackup.models.ScheduleRunType;
import com.azure.resourcemanager.recoveryservicesbackup.models.Settings;
import com.azure.resourcemanager.recoveryservicesbackup.models.SimpleRetentionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.SimpleSchedulePolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.SubProtectionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeekOfMonth;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionFormat;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.WorkloadType;
import com.azure.resourcemanager.recoveryservicesbackup.models.YearlyRetentionSchedule;
import java.time.OffsetDateTime;
import java.util.Arrays;
/**
* Samples for ProtectionPolicies CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/AzureWorkload/ProtectionPolicies_CreateOrUpdate_Complex.json
*/
/**
* Sample code: Create or Update Full Azure Workload Protection Policy.
*
* @param manager Entry point to RecoveryServicesBackupManager.
*/
public static void createOrUpdateFullAzureWorkloadProtectionPolicy(
com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager manager) {
manager.protectionPolicies().define("testPolicy1").withExistingVault("NetSDKTestRsVault", "SwaggerTestRg")
.withProperties(
new AzureVmWorkloadProtectionPolicy().withWorkLoadType(WorkloadType.SQLDATA_BASE)
.withSettings(new Settings().withTimeZone("Pacific Standard Time").withIssqlcompression(false))
.withSubProtectionPolicy(Arrays.asList(
new SubProtectionPolicy().withPolicyType(PolicyType.FULL)
.withSchedulePolicy(
new SimpleSchedulePolicy().withScheduleRunFrequency(ScheduleRunType.WEEKLY)
.withScheduleRunDays(Arrays.asList(DayOfWeek.SUNDAY, DayOfWeek.TUESDAY))
.withScheduleRunTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z"))))
.withRetentionPolicy(new LongTermRetentionPolicy()
.withWeeklySchedule(new WeeklyRetentionSchedule()
.withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY, DayOfWeek.TUESDAY))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z")))
.withRetentionDuration(new RetentionDuration().withCount(2)
.withDurationType(RetentionDurationType.WEEKS)))
.withMonthlySchedule(new MonthlyRetentionSchedule()
.withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY)
.withRetentionScheduleWeekly(
new WeeklyRetentionFormat().withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.SECOND)))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z")))
.withRetentionDuration(new RetentionDuration().withCount(1)
.withDurationType(RetentionDurationType.MONTHS)))
.withYearlySchedule(new YearlyRetentionSchedule()
.withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY)
.withMonthsOfYear(
Arrays.asList(MonthOfYear.JANUARY, MonthOfYear.JUNE, MonthOfYear.DECEMBER))
.withRetentionScheduleWeekly(
new WeeklyRetentionFormat().withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.LAST)))
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z")))
.withRetentionDuration(new RetentionDuration().withCount(1)
.withDurationType(RetentionDurationType.YEARS)))),
new SubProtectionPolicy().withPolicyType(PolicyType.DIFFERENTIAL)
.withSchedulePolicy(
new SimpleSchedulePolicy().withScheduleRunFrequency(ScheduleRunType.WEEKLY)
.withScheduleRunDays(Arrays.asList(DayOfWeek.FRIDAY))
.withScheduleRunTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z"))))
.withRetentionPolicy(new SimpleRetentionPolicy().withRetentionDuration(
new RetentionDuration().withCount(8).withDurationType(RetentionDurationType.DAYS))),
new SubProtectionPolicy().withPolicyType(PolicyType.LOG)
.withSchedulePolicy(new LogSchedulePolicy().withScheduleFrequencyInMins(60))
.withRetentionPolicy(new SimpleRetentionPolicy().withRetentionDuration(
new RetentionDuration().withCount(7).withDurationType(RetentionDurationType.DAYS))))))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.recoveryservicesbackup import RecoveryServicesBackupClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-recoveryservicesbackup
# USAGE
python protection_policies_create_or_update_complex.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 = RecoveryServicesBackupClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.protection_policies.create_or_update(
vault_name="NetSDKTestRsVault",
resource_group_name="SwaggerTestRg",
policy_name="testPolicy1",
parameters={
"properties": {
"backupManagementType": "AzureWorkload",
"settings": {"issqlcompression": False, "timeZone": "Pacific Standard Time"},
"subProtectionPolicy": [
{
"policyType": "Full",
"retentionPolicy": {
"monthlySchedule": {
"retentionDuration": {"count": 1, "durationType": "Months"},
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {"daysOfTheWeek": ["Sunday"], "weeksOfTheMonth": ["Second"]},
"retentionTimes": ["2018-01-24T10:00:00Z"],
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": ["Sunday", "Tuesday"],
"retentionDuration": {"count": 2, "durationType": "Weeks"},
"retentionTimes": ["2018-01-24T10:00:00Z"],
},
"yearlySchedule": {
"monthsOfYear": ["January", "June", "December"],
"retentionDuration": {"count": 1, "durationType": "Years"},
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {"daysOfTheWeek": ["Sunday"], "weeksOfTheMonth": ["Last"]},
"retentionTimes": ["2018-01-24T10:00:00Z"],
},
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunDays": ["Sunday", "Tuesday"],
"scheduleRunFrequency": "Weekly",
"scheduleRunTimes": ["2018-01-24T10:00:00Z"],
},
},
{
"policyType": "Differential",
"retentionPolicy": {
"retentionDuration": {"count": 8, "durationType": "Days"},
"retentionPolicyType": "SimpleRetentionPolicy",
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunDays": ["Friday"],
"scheduleRunFrequency": "Weekly",
"scheduleRunTimes": ["2018-01-24T10:00:00Z"],
},
},
{
"policyType": "Log",
"retentionPolicy": {
"retentionDuration": {"count": 7, "durationType": "Days"},
"retentionPolicyType": "SimpleRetentionPolicy",
},
"schedulePolicy": {"scheduleFrequencyInMins": 60, "schedulePolicyType": "LogSchedulePolicy"},
},
],
"workLoadType": "SQLDataBase",
}
},
)
print(response)
# x-ms-original-file: 2026-07-01/AzureWorkload/ProtectionPolicies_CreateOrUpdate_Complex.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 armrecoveryservicesbackup_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/recoveryservices/armrecoveryservicesbackup/v5"
)
// Generated from example definition: 2026-07-01/AzureWorkload/ProtectionPolicies_CreateOrUpdate_Complex.json
func ExampleProtectionPoliciesClient_CreateOrUpdate_createOrUpdateFullAzureWorkloadProtectionPolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armrecoveryservicesbackup.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewProtectionPoliciesClient().CreateOrUpdate(ctx, "NetSDKTestRsVault", "SwaggerTestRg", "testPolicy1", armrecoveryservicesbackup.ProtectionPolicyResource{
Properties: &armrecoveryservicesbackup.AzureVMWorkloadProtectionPolicy{
BackupManagementType: to.Ptr("AzureWorkload"),
Settings: &armrecoveryservicesbackup.Settings{
Issqlcompression: to.Ptr(false),
TimeZone: to.Ptr("Pacific Standard Time"),
},
SubProtectionPolicy: []*armrecoveryservicesbackup.SubProtectionPolicy{
{
PolicyType: to.Ptr(armrecoveryservicesbackup.PolicyTypeFull),
RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
MonthlySchedule: &armrecoveryservicesbackup.MonthlyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](1),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeMonths),
},
RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
to.Ptr(armrecoveryservicesbackup.WeekOfMonthSecond),
},
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
},
},
RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
WeeklySchedule: &armrecoveryservicesbackup.WeeklyRetentionSchedule{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
to.Ptr(armrecoveryservicesbackup.DayOfWeekTuesday),
},
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](2),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeWeeks),
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
},
},
YearlySchedule: &armrecoveryservicesbackup.YearlyRetentionSchedule{
MonthsOfYear: []*armrecoveryservicesbackup.MonthOfYear{
to.Ptr(armrecoveryservicesbackup.MonthOfYearJanuary),
to.Ptr(armrecoveryservicesbackup.MonthOfYearJune),
to.Ptr(armrecoveryservicesbackup.MonthOfYearDecember),
},
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](1),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeYears),
},
RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
to.Ptr(armrecoveryservicesbackup.WeekOfMonthLast),
},
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
},
},
},
SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
ScheduleRunDays: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
to.Ptr(armrecoveryservicesbackup.DayOfWeekTuesday),
},
ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeWeekly),
ScheduleRunTimes: []*time.Time{
to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
},
},
},
{
PolicyType: to.Ptr(armrecoveryservicesbackup.PolicyTypeDifferential),
RetentionPolicy: &armrecoveryservicesbackup.SimpleRetentionPolicy{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](8),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
},
RetentionPolicyType: to.Ptr("SimpleRetentionPolicy"),
},
SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
ScheduleRunDays: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekFriday),
},
ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeWeekly),
ScheduleRunTimes: []*time.Time{
to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
},
},
},
{
PolicyType: to.Ptr(armrecoveryservicesbackup.PolicyTypeLog),
RetentionPolicy: &armrecoveryservicesbackup.SimpleRetentionPolicy{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](7),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
},
RetentionPolicyType: to.Ptr("SimpleRetentionPolicy"),
},
SchedulePolicy: &armrecoveryservicesbackup.LogSchedulePolicy{
ScheduleFrequencyInMins: to.Ptr[int32](60),
SchedulePolicyType: to.Ptr("LogSchedulePolicy"),
},
},
},
WorkLoadType: to.Ptr(armrecoveryservicesbackup.WorkloadTypeSQLDataBase),
},
}, nil)
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 = armrecoveryservicesbackup.ProtectionPoliciesClientCreateOrUpdateResponse{
// ProtectionPolicyResource: armrecoveryservicesbackup.ProtectionPolicyResource{
// Name: to.Ptr("testPolicy1"),
// Type: to.Ptr("Microsoft.RecoveryServices/vaults/backupPolicies"),
// ID: to.Ptr("/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1"),
// Properties: &armrecoveryservicesbackup.AzureVMWorkloadProtectionPolicy{
// BackupManagementType: to.Ptr("AzureWorkload"),
// ProtectedItemsCount: to.Ptr[int32](0),
// Settings: &armrecoveryservicesbackup.Settings{
// Issqlcompression: to.Ptr(false),
// TimeZone: to.Ptr("Pacific Standard Time"),
// },
// SubProtectionPolicy: []*armrecoveryservicesbackup.SubProtectionPolicy{
// {
// PolicyType: to.Ptr(armrecoveryservicesbackup.PolicyTypeFull),
// RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
// MonthlySchedule: &armrecoveryservicesbackup.MonthlyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](1),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeMonths),
// },
// RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
// RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthSecond),
// },
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
// },
// },
// RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
// WeeklySchedule: &armrecoveryservicesbackup.WeeklyRetentionSchedule{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// to.Ptr(armrecoveryservicesbackup.DayOfWeekTuesday),
// },
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](2),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeWeeks),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
// },
// },
// YearlySchedule: &armrecoveryservicesbackup.YearlyRetentionSchedule{
// MonthsOfYear: []*armrecoveryservicesbackup.MonthOfYear{
// to.Ptr(armrecoveryservicesbackup.MonthOfYearJanuary),
// to.Ptr(armrecoveryservicesbackup.MonthOfYearJune),
// to.Ptr(armrecoveryservicesbackup.MonthOfYearDecember),
// },
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](1),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeYears),
// },
// RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
// RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthLast),
// },
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
// },
// },
// },
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
// ScheduleRunDays: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// to.Ptr(armrecoveryservicesbackup.DayOfWeekTuesday),
// },
// ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeWeekly),
// ScheduleRunTimes: []*time.Time{
// to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
// },
// ScheduleWeeklyFrequency: to.Ptr[int32](0),
// },
// },
// {
// PolicyType: to.Ptr(armrecoveryservicesbackup.PolicyTypeDifferential),
// RetentionPolicy: &armrecoveryservicesbackup.SimpleRetentionPolicy{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](8),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// RetentionPolicyType: to.Ptr("SimpleRetentionPolicy"),
// },
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
// ScheduleRunDays: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekFriday),
// },
// ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeWeekly),
// ScheduleRunTimes: []*time.Time{
// to.Ptr(time.Date(2018, time.January, 24, 10, 0, 0, 0, time.UTC)),
// },
// ScheduleWeeklyFrequency: to.Ptr[int32](0),
// },
// },
// {
// PolicyType: to.Ptr(armrecoveryservicesbackup.PolicyTypeLog),
// RetentionPolicy: &armrecoveryservicesbackup.SimpleRetentionPolicy{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](7),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// RetentionPolicyType: to.Ptr("SimpleRetentionPolicy"),
// },
// SchedulePolicy: &armrecoveryservicesbackup.LogSchedulePolicy{
// ScheduleFrequencyInMins: to.Ptr[int32](60),
// SchedulePolicyType: to.Ptr("LogSchedulePolicy"),
// },
// },
// },
// WorkLoadType: to.Ptr(armrecoveryservicesbackup.WorkloadTypeSQLDataBase),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { RecoveryServicesBackupClient } = require("@azure/arm-recoveryservicesbackup");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
*
* @summary creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
* x-ms-original-file: 2026-07-01/AzureWorkload/ProtectionPolicies_CreateOrUpdate_Complex.json
*/
async function createOrUpdateFullAzureWorkloadProtectionPolicy() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
"NetSDKTestRsVault",
"SwaggerTestRg",
"testPolicy1",
{
properties: {
backupManagementType: "AzureWorkload",
settings: { issqlcompression: false, timeZone: "Pacific Standard Time" },
subProtectionPolicy: [
{
policyType: "Full",
retentionPolicy: {
monthlySchedule: {
retentionDuration: { count: 1, durationType: "Months" },
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: { daysOfTheWeek: ["Sunday"], weeksOfTheMonth: ["Second"] },
retentionTimes: [new Date("2018-01-24T10:00:00Z")],
},
retentionPolicyType: "LongTermRetentionPolicy",
weeklySchedule: {
daysOfTheWeek: ["Sunday", "Tuesday"],
retentionDuration: { count: 2, durationType: "Weeks" },
retentionTimes: [new Date("2018-01-24T10:00:00Z")],
},
yearlySchedule: {
monthsOfYear: ["January", "June", "December"],
retentionDuration: { count: 1, durationType: "Years" },
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: { daysOfTheWeek: ["Sunday"], weeksOfTheMonth: ["Last"] },
retentionTimes: [new Date("2018-01-24T10:00:00Z")],
},
},
schedulePolicy: {
schedulePolicyType: "SimpleSchedulePolicy",
scheduleRunDays: ["Sunday", "Tuesday"],
scheduleRunFrequency: "Weekly",
scheduleRunTimes: [new Date("2018-01-24T10:00:00Z")],
},
},
{
policyType: "Differential",
retentionPolicy: {
retentionDuration: { count: 8, durationType: "Days" },
retentionPolicyType: "SimpleRetentionPolicy",
},
schedulePolicy: {
schedulePolicyType: "SimpleSchedulePolicy",
scheduleRunDays: ["Friday"],
scheduleRunFrequency: "Weekly",
scheduleRunTimes: [new Date("2018-01-24T10:00:00Z")],
},
},
{
policyType: "Log",
retentionPolicy: {
retentionDuration: { count: 7, durationType: "Days" },
retentionPolicyType: "SimpleRetentionPolicy",
},
schedulePolicy: {
scheduleFrequencyInMins: 60,
schedulePolicyType: "LogSchedulePolicy",
},
},
],
workLoadType: "SQLDataBase",
},
},
);
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
Beispiel für eine Antwort
{
"name": "testPolicy1",
"type": "Microsoft.RecoveryServices/vaults/backupPolicies",
"id": "/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1",
"properties": {
"backupManagementType": "AzureWorkload",
"protectedItemsCount": 0,
"settings": {
"issqlcompression": false,
"timeZone": "Pacific Standard Time"
},
"subProtectionPolicy": [
{
"policyType": "Full",
"retentionPolicy": {
"monthlySchedule": {
"retentionDuration": {
"count": 1,
"durationType": "Months"
},
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"Second"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
]
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday",
"Tuesday"
],
"retentionDuration": {
"count": 2,
"durationType": "Weeks"
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
]
},
"yearlySchedule": {
"monthsOfYear": [
"January",
"June",
"December"
],
"retentionDuration": {
"count": 1,
"durationType": "Years"
},
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"Last"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
]
}
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunDays": [
"Sunday",
"Tuesday"
],
"scheduleRunFrequency": "Weekly",
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
],
"scheduleWeeklyFrequency": 0
}
},
{
"policyType": "Differential",
"retentionPolicy": {
"retentionDuration": {
"count": 8,
"durationType": "Days"
},
"retentionPolicyType": "SimpleRetentionPolicy"
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunDays": [
"Friday"
],
"scheduleRunFrequency": "Weekly",
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
],
"scheduleWeeklyFrequency": 0
}
},
{
"policyType": "Log",
"retentionPolicy": {
"retentionDuration": {
"count": 7,
"durationType": "Days"
},
"retentionPolicyType": "SimpleRetentionPolicy"
},
"schedulePolicy": {
"scheduleFrequencyInMins": 60,
"schedulePolicyType": "LogSchedulePolicy"
}
}
],
"workLoadType": "SQLDataBase"
}
}
Azure-AsyncOperation: https://management.azure.com/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1/operations/00000000-0000-0000-0000-000000000000?api-version=2016-06-01
Location: https://management.azure.com/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1/operationResults/00000000-0000-0000-0000-000000000000?api-version=2016-06-01
Retry-After: 60
Create or Update Hourly Azure Storage Protection Policy
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/newPolicy2?api-version=2026-07-01
{
"properties": {
"backupManagementType": "AzureStorage",
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {
"count": 5,
"durationType": "Days"
},
"retentionTimes": null
},
"monthlySchedule": {
"retentionDuration": {
"count": 60,
"durationType": "Months"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": null
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
},
"retentionTimes": null
},
"yearlySchedule": {
"monthsOfYear": [
"January"
],
"retentionDuration": {
"count": 10,
"durationType": "Years"
},
"retentionScheduleDaily": null,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": null
}
},
"schedulePolicy": {
"hourlySchedule": {
"interval": 4,
"scheduleWindowDuration": 12,
"scheduleWindowStartTime": "2021-09-29T08:00:00.000Z"
},
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Hourly"
},
"timeZone": "UTC",
"workLoadType": "AzureFileShare"
}
}
import com.azure.resourcemanager.recoveryservicesbackup.models.AzureFileShareProtectionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.DailyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.DayOfWeek;
import com.azure.resourcemanager.recoveryservicesbackup.models.HourlySchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.LongTermRetentionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.MonthOfYear;
import com.azure.resourcemanager.recoveryservicesbackup.models.MonthlyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDuration;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDurationType;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionScheduleFormat;
import com.azure.resourcemanager.recoveryservicesbackup.models.ScheduleRunType;
import com.azure.resourcemanager.recoveryservicesbackup.models.SimpleSchedulePolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeekOfMonth;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionFormat;
import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.WorkloadType;
import com.azure.resourcemanager.recoveryservicesbackup.models.YearlyRetentionSchedule;
import java.time.OffsetDateTime;
import java.util.Arrays;
/**
* Samples for ProtectionPolicies CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/AzureStorage/ProtectionPolicies_CreateOrUpdate_Hourly.json
*/
/**
* Sample code: Create or Update Hourly Azure Storage Protection Policy.
*
* @param manager Entry point to RecoveryServicesBackupManager.
*/
public static void createOrUpdateHourlyAzureStorageProtectionPolicy(
com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager manager) {
manager.protectionPolicies().define("newPolicy2").withExistingVault("swaggertestvault", "SwaggerTestRg")
.withProperties(new AzureFileShareProtectionPolicy().withWorkLoadType(WorkloadType.AZURE_FILE_SHARE)
.withSchedulePolicy(new SimpleSchedulePolicy().withScheduleRunFrequency(ScheduleRunType.HOURLY)
.withHourlySchedule(new HourlySchedule().withInterval(4)
.withScheduleWindowStartTime(OffsetDateTime.parse("2021-09-29T08:00:00.000Z"))
.withScheduleWindowDuration(12)))
.withRetentionPolicy(
new LongTermRetentionPolicy()
.withDailySchedule(new DailyRetentionSchedule().withRetentionDuration(
new RetentionDuration().withCount(5).withDurationType(RetentionDurationType.DAYS)))
.withWeeklySchedule(
new WeeklyRetentionSchedule().withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withRetentionDuration(new RetentionDuration().withCount(12)
.withDurationType(RetentionDurationType.WEEKS)))
.withMonthlySchedule(new MonthlyRetentionSchedule()
.withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY)
.withRetentionScheduleWeekly(
new WeeklyRetentionFormat().withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.FIRST)))
.withRetentionDuration(
new RetentionDuration().withCount(60).withDurationType(RetentionDurationType.MONTHS)))
.withYearlySchedule(new YearlyRetentionSchedule()
.withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY)
.withMonthsOfYear(Arrays.asList(MonthOfYear.JANUARY))
.withRetentionScheduleWeekly(
new WeeklyRetentionFormat().withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY))
.withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.FIRST)))
.withRetentionDuration(
new RetentionDuration().withCount(10).withDurationType(RetentionDurationType.YEARS))))
.withTimeZone("UTC"))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.recoveryservicesbackup import RecoveryServicesBackupClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-recoveryservicesbackup
# USAGE
python protection_policies_create_or_update_hourly.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 = RecoveryServicesBackupClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.protection_policies.create_or_update(
vault_name="swaggertestvault",
resource_group_name="SwaggerTestRg",
policy_name="newPolicy2",
parameters={
"properties": {
"backupManagementType": "AzureStorage",
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {"count": 5, "durationType": "Days"},
"retentionTimes": None,
},
"monthlySchedule": {
"retentionDuration": {"count": 60, "durationType": "Months"},
"retentionScheduleDaily": None,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {"daysOfTheWeek": ["Sunday"], "weeksOfTheMonth": ["First"]},
"retentionTimes": None,
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": ["Sunday"],
"retentionDuration": {"count": 12, "durationType": "Weeks"},
"retentionTimes": None,
},
"yearlySchedule": {
"monthsOfYear": ["January"],
"retentionDuration": {"count": 10, "durationType": "Years"},
"retentionScheduleDaily": None,
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {"daysOfTheWeek": ["Sunday"], "weeksOfTheMonth": ["First"]},
"retentionTimes": None,
},
},
"schedulePolicy": {
"hourlySchedule": {
"interval": 4,
"scheduleWindowDuration": 12,
"scheduleWindowStartTime": "2021-09-29T08:00:00.000Z",
},
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Hourly",
},
"timeZone": "UTC",
"workLoadType": "AzureFileShare",
}
},
)
print(response)
# x-ms-original-file: 2026-07-01/AzureStorage/ProtectionPolicies_CreateOrUpdate_Hourly.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 armrecoveryservicesbackup_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/recoveryservices/armrecoveryservicesbackup/v5"
)
// Generated from example definition: 2026-07-01/AzureStorage/ProtectionPolicies_CreateOrUpdate_Hourly.json
func ExampleProtectionPoliciesClient_CreateOrUpdate_createOrUpdateHourlyAzureStorageProtectionPolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armrecoveryservicesbackup.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewProtectionPoliciesClient().CreateOrUpdate(ctx, "swaggertestvault", "SwaggerTestRg", "newPolicy2", armrecoveryservicesbackup.ProtectionPolicyResource{
Properties: &armrecoveryservicesbackup.AzureFileShareProtectionPolicy{
BackupManagementType: to.Ptr("AzureStorage"),
RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](5),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
},
},
MonthlySchedule: &armrecoveryservicesbackup.MonthlyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](60),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeMonths),
},
RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
},
},
},
RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
WeeklySchedule: &armrecoveryservicesbackup.WeeklyRetentionSchedule{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](12),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeWeeks),
},
},
YearlySchedule: &armrecoveryservicesbackup.YearlyRetentionSchedule{
MonthsOfYear: []*armrecoveryservicesbackup.MonthOfYear{
to.Ptr(armrecoveryservicesbackup.MonthOfYearJanuary),
},
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](10),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeYears),
},
RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
},
WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
},
},
},
},
SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
HourlySchedule: &armrecoveryservicesbackup.HourlySchedule{
Interval: to.Ptr[int32](4),
ScheduleWindowDuration: to.Ptr[int32](12),
ScheduleWindowStartTime: to.Ptr(time.Date(2021, time.September, 29, 8, 0, 0, 0, time.UTC)),
},
SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeHourly),
},
TimeZone: to.Ptr("UTC"),
WorkLoadType: to.Ptr(armrecoveryservicesbackup.WorkloadTypeAzureFileShare),
},
}, nil)
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 = armrecoveryservicesbackup.ProtectionPoliciesClientCreateOrUpdateResponse{
// ProtectionPolicyResource: armrecoveryservicesbackup.ProtectionPolicyResource{
// Name: to.Ptr("newPolicy2"),
// Type: to.Ptr("Microsoft.RecoveryServices/vaults/backupPolicies"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/newPolicy2"),
// Properties: &armrecoveryservicesbackup.AzureFileShareProtectionPolicy{
// BackupManagementType: to.Ptr("AzureStorage"),
// ProtectedItemsCount: to.Ptr[int32](0),
// RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
// DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](5),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.September, 29, 20, 0, 0, 0, time.UTC)),
// },
// },
// MonthlySchedule: &armrecoveryservicesbackup.MonthlyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](60),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeMonths),
// },
// RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
// RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
// },
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.September, 29, 20, 0, 0, 0, time.UTC)),
// },
// },
// RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
// WeeklySchedule: &armrecoveryservicesbackup.WeeklyRetentionSchedule{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](12),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeWeeks),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.September, 29, 20, 0, 0, 0, time.UTC)),
// },
// },
// YearlySchedule: &armrecoveryservicesbackup.YearlyRetentionSchedule{
// MonthsOfYear: []*armrecoveryservicesbackup.MonthOfYear{
// to.Ptr(armrecoveryservicesbackup.MonthOfYearJanuary),
// },
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](10),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeYears),
// },
// RetentionScheduleFormatType: to.Ptr(armrecoveryservicesbackup.RetentionScheduleFormatWeekly),
// RetentionScheduleWeekly: &armrecoveryservicesbackup.WeeklyRetentionFormat{
// DaysOfTheWeek: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekSunday),
// },
// WeeksOfTheMonth: []*armrecoveryservicesbackup.WeekOfMonth{
// to.Ptr(armrecoveryservicesbackup.WeekOfMonthFirst),
// },
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2021, time.September, 29, 20, 0, 0, 0, time.UTC)),
// },
// },
// },
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
// HourlySchedule: &armrecoveryservicesbackup.HourlySchedule{
// Interval: to.Ptr[int32](4),
// ScheduleWindowDuration: to.Ptr[int32](12),
// ScheduleWindowStartTime: to.Ptr(time.Date(2021, time.September, 29, 8, 0, 0, 0, time.UTC)),
// },
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
// ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeHourly),
// ScheduleWeeklyFrequency: to.Ptr[int32](0),
// },
// TimeZone: to.Ptr("UTC"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { RecoveryServicesBackupClient } = require("@azure/arm-recoveryservicesbackup");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
*
* @summary creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
* x-ms-original-file: 2026-07-01/AzureStorage/ProtectionPolicies_CreateOrUpdate_Hourly.json
*/
async function createOrUpdateHourlyAzureStorageProtectionPolicy() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
"swaggertestvault",
"SwaggerTestRg",
"newPolicy2",
{
properties: {
backupManagementType: "AzureStorage",
retentionPolicy: {
dailySchedule: { retentionDuration: { count: 5, durationType: "Days" } },
monthlySchedule: {
retentionDuration: { count: 60, durationType: "Months" },
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: { daysOfTheWeek: ["Sunday"], weeksOfTheMonth: ["First"] },
},
retentionPolicyType: "LongTermRetentionPolicy",
weeklySchedule: {
daysOfTheWeek: ["Sunday"],
retentionDuration: { count: 12, durationType: "Weeks" },
},
yearlySchedule: {
monthsOfYear: ["January"],
retentionDuration: { count: 10, durationType: "Years" },
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: { daysOfTheWeek: ["Sunday"], weeksOfTheMonth: ["First"] },
},
},
schedulePolicy: {
hourlySchedule: {
interval: 4,
scheduleWindowDuration: 12,
scheduleWindowStartTime: new Date("2021-09-29T08:00:00.000Z"),
},
schedulePolicyType: "SimpleSchedulePolicy",
scheduleRunFrequency: "Hourly",
},
timeZone: "UTC",
workLoadType: "AzureFileShare",
},
},
);
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
Beispiel für eine Antwort
{
"name": "newPolicy2",
"type": "Microsoft.RecoveryServices/vaults/backupPolicies",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/newPolicy2",
"properties": {
"backupManagementType": "AzureStorage",
"protectedItemsCount": 0,
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {
"count": 5,
"durationType": "Days"
},
"retentionTimes": [
"2021-09-29T20:00:00Z"
]
},
"monthlySchedule": {
"retentionDuration": {
"count": 60,
"durationType": "Months"
},
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-09-29T20:00:00Z"
]
},
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
},
"retentionTimes": [
"2021-09-29T20:00:00Z"
]
},
"yearlySchedule": {
"monthsOfYear": [
"January"
],
"retentionDuration": {
"count": 10,
"durationType": "Years"
},
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-09-29T20:00:00Z"
]
}
},
"schedulePolicy": {
"hourlySchedule": {
"interval": 4,
"scheduleWindowDuration": 12,
"scheduleWindowStartTime": "2021-09-29T08:00:00Z"
},
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Hourly",
"scheduleWeeklyFrequency": 0
},
"timeZone": "UTC"
}
}
Azure-AsyncOperation: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/newPolicy2/operations/00000000-0000-0000-0000-000000000000?api-version=2016-06-01
Location: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/newPolicy2/operationResults/00000000-0000-0000-0000-000000000000?api-version=2016-06-01
Retry-After: 60
Create or Update Simple Azure Vm Protection Policy
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1?api-version=2026-07-01
{
"properties": {
"backupManagementType": "AzureIaasVM",
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {
"count": 1,
"durationType": "Days"
},
"retentionTimes": [
"2018-01-24T02:00:00Z"
]
},
"retentionPolicyType": "LongTermRetentionPolicy"
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": [
"2018-01-24T02:00:00Z"
]
},
"timeZone": "Pacific Standard Time"
}
}
import com.azure.resourcemanager.recoveryservicesbackup.models.AzureIaaSvmProtectionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.DailyRetentionSchedule;
import com.azure.resourcemanager.recoveryservicesbackup.models.LongTermRetentionPolicy;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDuration;
import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDurationType;
import com.azure.resourcemanager.recoveryservicesbackup.models.ScheduleRunType;
import com.azure.resourcemanager.recoveryservicesbackup.models.SimpleSchedulePolicy;
import java.time.OffsetDateTime;
import java.util.Arrays;
/**
* Samples for ProtectionPolicies CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Simple.json
*/
/**
* Sample code: Create or Update Simple Azure Vm Protection Policy.
*
* @param manager Entry point to RecoveryServicesBackupManager.
*/
public static void createOrUpdateSimpleAzureVmProtectionPolicy(
com.azure.resourcemanager.recoveryservicesbackup.RecoveryServicesBackupManager manager) {
manager
.protectionPolicies().define("testPolicy1").withExistingVault("NetSDKTestRsVault",
"SwaggerTestRg")
.withProperties(new AzureIaaSvmProtectionPolicy()
.withSchedulePolicy(new SimpleSchedulePolicy().withScheduleRunFrequency(ScheduleRunType.DAILY)
.withScheduleRunTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T02:00:00Z"))))
.withRetentionPolicy(new LongTermRetentionPolicy().withDailySchedule(new DailyRetentionSchedule()
.withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T02:00:00Z")))
.withRetentionDuration(
new RetentionDuration().withCount(1).withDurationType(RetentionDurationType.DAYS))))
.withTimeZone("Pacific Standard Time"))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.recoveryservicesbackup import RecoveryServicesBackupClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-recoveryservicesbackup
# USAGE
python protection_policies_create_or_update_simple.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 = RecoveryServicesBackupClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.protection_policies.create_or_update(
vault_name="NetSDKTestRsVault",
resource_group_name="SwaggerTestRg",
policy_name="testPolicy1",
parameters={
"properties": {
"backupManagementType": "AzureIaasVM",
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {"count": 1, "durationType": "Days"},
"retentionTimes": ["2018-01-24T02:00:00Z"],
},
"retentionPolicyType": "LongTermRetentionPolicy",
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": ["2018-01-24T02:00:00Z"],
},
"timeZone": "Pacific Standard Time",
}
},
)
print(response)
# x-ms-original-file: 2026-07-01/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Simple.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 armrecoveryservicesbackup_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/recoveryservices/armrecoveryservicesbackup/v5"
)
// Generated from example definition: 2026-07-01/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Simple.json
func ExampleProtectionPoliciesClient_CreateOrUpdate_createOrUpdateSimpleAzureVMProtectionPolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armrecoveryservicesbackup.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewProtectionPoliciesClient().CreateOrUpdate(ctx, "NetSDKTestRsVault", "SwaggerTestRg", "testPolicy1", armrecoveryservicesbackup.ProtectionPolicyResource{
Properties: &armrecoveryservicesbackup.AzureIaaSVMProtectionPolicy{
BackupManagementType: to.Ptr("AzureIaasVM"),
RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](1),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
},
RetentionTimes: []*time.Time{
to.Ptr(time.Date(2018, time.January, 24, 2, 0, 0, 0, time.UTC)),
},
},
RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
},
SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeDaily),
ScheduleRunTimes: []*time.Time{
to.Ptr(time.Date(2018, time.January, 24, 2, 0, 0, 0, time.UTC)),
},
},
TimeZone: to.Ptr("Pacific Standard Time"),
},
}, nil)
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 = armrecoveryservicesbackup.ProtectionPoliciesClientCreateOrUpdateResponse{
// ProtectionPolicyResource: armrecoveryservicesbackup.ProtectionPolicyResource{
// Name: to.Ptr("testPolicy1"),
// Type: to.Ptr("Microsoft.RecoveryServices/vaults/backupPolicies"),
// ID: to.Ptr("/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1"),
// Properties: &armrecoveryservicesbackup.AzureIaaSVMProtectionPolicy{
// BackupManagementType: to.Ptr("AzureIaasVM"),
// ProtectedItemsCount: to.Ptr[int32](0),
// RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
// DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](1),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(time.Date(2018, time.January, 24, 2, 0, 0, 0, time.UTC)),
// },
// },
// RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
// },
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
// ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeDaily),
// ScheduleRunTimes: []*time.Time{
// to.Ptr(time.Date(2018, time.January, 24, 2, 0, 0, 0, time.UTC)),
// },
// ScheduleWeeklyFrequency: to.Ptr[int32](0),
// },
// TimeZone: to.Ptr("Pacific Standard Time"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { RecoveryServicesBackupClient } = require("@azure/arm-recoveryservicesbackup");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
*
* @summary creates or modifies a backup policy. This is an asynchronous operation. Status of the operation can be fetched
* using GetPolicyOperationResult API.
* x-ms-original-file: 2026-07-01/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Simple.json
*/
async function createOrUpdateSimpleAzureVmProtectionPolicy() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
"NetSDKTestRsVault",
"SwaggerTestRg",
"testPolicy1",
{
properties: {
backupManagementType: "AzureIaasVM",
retentionPolicy: {
dailySchedule: {
retentionDuration: { count: 1, durationType: "Days" },
retentionTimes: [new Date("2018-01-24T02:00:00Z")],
},
retentionPolicyType: "LongTermRetentionPolicy",
},
schedulePolicy: {
schedulePolicyType: "SimpleSchedulePolicy",
scheduleRunFrequency: "Daily",
scheduleRunTimes: [new Date("2018-01-24T02:00:00Z")],
},
timeZone: "Pacific Standard Time",
},
},
);
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
Beispiel für eine Antwort
{
"name": "testPolicy1",
"type": "Microsoft.RecoveryServices/vaults/backupPolicies",
"id": "/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1",
"properties": {
"backupManagementType": "AzureIaasVM",
"protectedItemsCount": 0,
"retentionPolicy": {
"dailySchedule": {
"retentionDuration": {
"count": 1,
"durationType": "Days"
},
"retentionTimes": [
"2018-01-24T02:00:00Z"
]
},
"retentionPolicyType": "LongTermRetentionPolicy"
},
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": [
"2018-01-24T02:00:00Z"
],
"scheduleWeeklyFrequency": 0
},
"timeZone": "Pacific Standard Time"
}
}
Azure-AsyncOperation: https://management.azure.com/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1/operations/00000000-0000-0000-0000-000000000000?api-version=2016-06-01
Location: https://management.azure.com/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1/operationResults/00000000-0000-0000-0000-000000000000?api-version=2016-06-01
Retry-After: 60
Definitionen
AzureFileShareProtectionPolicy
Objekt
AzureStorage-Sicherungsrichtlinie.
| Name |
Typ |
Beschreibung |
|
backupManagementType
|
string:
AzureStorage
|
Diese Eigenschaft wird als Diskriminator für die Entscheidung der spezifischen Typen in der polymorphen Kette von Typen verwendet.
|
|
protectedItemsCount
|
integer
(int32)
|
Die Anzahl der Elemente, die dieser Richtlinie zugeordnet sind.
|
|
resourceGuardOperationRequests
|
string[]
|
ResourceGuard-Vorgangsanforderungen
|
|
retentionPolicy
|
RetentionPolicy:
|
Aufbewahrungsrichtlinie mit den Details zu Aufbewahrungsbereichen für Sicherungskopien.
|
|
schedulePolicy
|
SchedulePolicy:
|
Sicherungszeitplan, der als Teil der Sicherungsrichtlinie angegeben ist.
|
|
timeZone
|
string
|
Optionale TimeZone-Eingabe als Zeichenfolge. Beispiel: TimeZone = "Pacific Standard Time".
|
|
vaultRetentionPolicy
|
VaultRetentionPolicy
|
Aufbewahrungsrichtlinie mit den Details zu gehärteten Aufbewahrungsbereichen für Sicherungskopien.
|
|
workLoadType
|
WorkloadType
|
Art der Arbeitsauslastung für die Sicherungsverwaltung
|
AzureIaaSVMProtectionPolicy
Objekt
Workloadspezifische Sicherungsrichtlinie für iaaS-VM.
| Name |
Typ |
Beschreibung |
|
backupManagementType
|
string:
AzureIaasVM
|
Diese Eigenschaft wird als Diskriminator für die Entscheidung der spezifischen Typen in der polymorphen Kette von Typen verwendet.
|
|
instantRPDetails
|
InstantRPAdditionalDetails
|
|
|
instantRpRetentionRangeInDays
|
integer
(int32)
|
Aufbewahrungsrichtlinienbereich für Sofort-RP in Tagen
|
|
policyType
|
IAASVMPolicyType
|
|
|
protectedItemsCount
|
integer
(int32)
|
Die Anzahl der Elemente, die dieser Richtlinie zugeordnet sind.
|
|
resourceGuardOperationRequests
|
string[]
|
ResourceGuard-Vorgangsanforderungen
|
|
retentionPolicy
|
RetentionPolicy:
|
Aufbewahrungsrichtlinie mit den Details zu Aufbewahrungsbereichen für Sicherungskopien.
|
|
schedulePolicy
|
SchedulePolicy:
|
Sicherungszeitplan, der als Teil der Sicherungsrichtlinie angegeben ist.
|
|
snapshotConsistencyType
|
IaasVMSnapshotConsistencyType
|
|
|
tieringPolicy
|
<string,
TieringPolicy>
|
Die Tieringrichtlinie zum automatischen Verschieben von RPs auf eine andere Ebene ist "Zielebene", die in der Enumeration "RecoveryPointTierType" definiert ist.
Die Ebenenrichtlinie gibt die Kriterien an, die RP auf die Zielebene verschoben werden sollen.
|
|
timeZone
|
string
|
Optionale TimeZone-Eingabe als Zeichenfolge. Beispiel: TimeZone = "Pacific Standard Time".
|
AzureSqlProtectionPolicy
Objekt
Azure SQL workload-spezifische Backup-Policy.
| Name |
Typ |
Beschreibung |
|
backupManagementType
|
string:
AzureSql
|
Diese Eigenschaft wird als Diskriminator für die Entscheidung der spezifischen Typen in der polymorphen Kette von Typen verwendet.
|
|
protectedItemsCount
|
integer
(int32)
|
Die Anzahl der Elemente, die dieser Richtlinie zugeordnet sind.
|
|
resourceGuardOperationRequests
|
string[]
|
ResourceGuard-Vorgangsanforderungen
|
|
retentionPolicy
|
RetentionPolicy:
|
Details zur Aufbewahrungsrichtlinie.
|
AzureVmWorkloadProtectionPolicy
Objekt
Azure VM (Mercury) workload-spezifische Backup-Richtlinie.
| Name |
Typ |
Beschreibung |
|
backupManagementType
|
string:
AzureWorkload
|
Diese Eigenschaft wird als Diskriminator für die Entscheidung der spezifischen Typen in der polymorphen Kette von Typen verwendet.
|
|
makePolicyConsistent
|
boolean
|
Beheben der Richtlinieninkonsistenz
|
|
protectedItemsCount
|
integer
(int32)
|
Die Anzahl der Elemente, die dieser Richtlinie zugeordnet sind.
|
|
resourceGuardOperationRequests
|
string[]
|
ResourceGuard-Vorgangsanforderungen
|
|
settings
|
Settings
|
Allgemeine Einstellungen für die Sicherungsverwaltung
|
|
subProtectionPolicy
|
SubProtectionPolicy[]
|
Liste der Unterschutzrichtlinien, die Zeitplan und Aufbewahrung umfassen
|
|
workLoadType
|
WorkloadType
|
Art der Arbeitsauslastung für die Sicherungsverwaltung
|
createdByType
Enumeration
Der Identitätstyp, der die Ressource erstellt hat.
| Wert |
Beschreibung |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
Objekt
Tägliches Aufbewahrungsformat.
| Name |
Typ |
Beschreibung |
|
daysOfTheMonth
|
Day[]
|
Liste der Tage des Monats.
|
DailyRetentionSchedule
Objekt
Täglicher Aufbewahrungszeitplan.
| Name |
Typ |
Beschreibung |
|
retentionDuration
|
RetentionDuration
|
Aufbewahrungsdauer der Aufbewahrungsrichtlinie.
|
|
retentionTimes
|
string[]
(date-time)
|
Aufbewahrungszeiten der Aufbewahrungsrichtlinie.
|
DailySchedule
Objekt
| Name |
Typ |
Beschreibung |
|
scheduleRunTimes
|
string[]
(date-time)
|
Liste der Tageszeiten, zu denen dieser Zeitplan ausgeführt werden muss.
|
Day
Objekt
Wochentag.
| Name |
Typ |
Beschreibung |
|
date
|
integer
(int32)
|
Datum des Monats
|
|
isLast
|
boolean
|
Gibt an, ob Datum das letzte Datum des Monats ist.
|
DayOfWeek
Enumeration
| Wert |
Beschreibung |
|
Sunday
|
|
|
Monday
|
|
|
Tuesday
|
|
|
Wednesday
|
|
|
Thursday
|
|
|
Friday
|
|
|
Saturday
|
|
ErrorDetail
Objekt
Error Detail-Klasse, die Code, Message und Recommendations kapselt.
| Name |
Typ |
Beschreibung |
|
code
|
string
|
Fehlercode.
|
|
message
|
string
|
Fehlermeldung im Zusammenhang mit dem Code.
|
|
recommendations
|
string[]
|
Liste der Empfehlungszeichenfolgen.
|
ErrorResponse
Objekt
Fehlerantwort
| Name |
Typ |
Beschreibung |
|
error
|
ErrorDetail
|
Das Fehlerobjekt.
|
GenericProtectionPolicy
Objekt
Azure VM (Mercury) workload-spezifische Backup-Richtlinie.
| Name |
Typ |
Beschreibung |
|
backupManagementType
|
string:
GenericProtectionPolicy
|
Diese Eigenschaft wird als Diskriminator für die Entscheidung der spezifischen Typen in der polymorphen Kette von Typen verwendet.
|
|
fabricName
|
string
|
Name des Fabric dieser Richtlinie.
|
|
protectedItemsCount
|
integer
(int32)
|
Die Anzahl der Elemente, die dieser Richtlinie zugeordnet sind.
|
|
resourceGuardOperationRequests
|
string[]
|
ResourceGuard-Vorgangsanforderungen
|
|
subProtectionPolicy
|
SubProtectionPolicy[]
|
Liste der Unterschutzrichtlinien, die Zeitplan und Aufbewahrung umfassen
|
|
timeZone
|
string
|
Optionale TimeZone-Eingabe als Zeichenfolge. Beispiel: TimeZone = "Pacific Standard Time".
|
HourlySchedule
Objekt
| Name |
Typ |
Beschreibung |
|
interval
|
integer
(int32)
|
Intervall, in dem die Sicherung ausgelöst werden muss. Für stündlich kann der Wert 4/6/8/12 sein
|
|
scheduleWindowDuration
|
integer
(int32)
|
So geben Sie die Dauer des Sicherungsfensters an
|
|
scheduleWindowStartTime
|
string
(date-time)
|
So geben Sie die Startzeit des Sicherungsfensters an
|
IAASVMPolicyType
Enumeration
| Wert |
Beschreibung |
|
Invalid
|
|
|
V1
|
|
|
V2
|
|
IaasVMSnapshotConsistencyType
Enumeration
| Wert |
Beschreibung |
|
OnlyCrashConsistent
|
|
InstantRPAdditionalDetails
Objekt
| Name |
Typ |
Beschreibung |
|
azureBackupRGNamePrefix
|
string
|
|
|
azureBackupRGNameSuffix
|
string
|
|
LogSchedulePolicy
Objekt
Protokollrichtlinienzeitplan.
| Name |
Typ |
Beschreibung |
|
scheduleFrequencyInMins
|
integer
(int32)
|
Häufigkeit des Protokollplanvorgangs dieser Richtlinie in Minuten.
|
|
schedulePolicyType
|
string:
LogSchedulePolicy
|
Diese Eigenschaft wird als Diskriminator für die Entscheidung der spezifischen Typen in der polymorphen Kette von Typen verwendet.
|
LongTermRetentionPolicy
Objekt
Langfristige Aufbewahrungsrichtlinie.
| Name |
Typ |
Beschreibung |
|
dailySchedule
|
DailyRetentionSchedule
|
Täglicher Aufbewahrungszeitplan der Schutzrichtlinie.
|
|
monthlySchedule
|
MonthlyRetentionSchedule
|
Monatlicher Aufbewahrungszeitplan der Schutzrichtlinie.
|
|
retentionPolicyType
|
string:
LongTermRetentionPolicy
|
Diese Eigenschaft wird als Diskriminator für die Entscheidung der spezifischen Typen in der polymorphen Kette von Typen verwendet.
|
|
weeklySchedule
|
WeeklyRetentionSchedule
|
Wöchentlicher Aufbewahrungszeitplan der Schutzrichtlinie.
|
|
yearlySchedule
|
YearlyRetentionSchedule
|
Jährlicher Aufbewahrungszeitplan der Schutzrichtlinie.
|
LongTermSchedulePolicy
Objekt
Langfristiger Richtlinienzeitplan.
| Name |
Typ |
Beschreibung |
|
schedulePolicyType
|
string:
LongTermSchedulePolicy
|
Diese Eigenschaft wird als Diskriminator für die Entscheidung der spezifischen Typen in der polymorphen Kette von Typen verwendet.
|
MabProtectionPolicy
Objekt
Mab containerspezifische Sicherungsrichtlinie.
| Name |
Typ |
Beschreibung |
|
backupManagementType
|
string:
MAB
|
Diese Eigenschaft wird als Diskriminator für die Entscheidung der spezifischen Typen in der polymorphen Kette von Typen verwendet.
|
|
protectedItemsCount
|
integer
(int32)
|
Die Anzahl der Elemente, die dieser Richtlinie zugeordnet sind.
|
|
resourceGuardOperationRequests
|
string[]
|
ResourceGuard-Vorgangsanforderungen
|
|
retentionPolicy
|
RetentionPolicy:
|
Details zur Aufbewahrungsrichtlinie.
|
|
schedulePolicy
|
SchedulePolicy:
|
Sicherungszeitplan der Sicherungsrichtlinie.
|
MonthlyRetentionSchedule
Objekt
Monatlicher Aufbewahrungszeitplan.
| Name |
Typ |
Beschreibung |
|
retentionDuration
|
RetentionDuration
|
Aufbewahrungsdauer der Aufbewahrungsrichtlinie.
|
|
retentionScheduleDaily
|
DailyRetentionFormat
|
Tägliches Aufbewahrungsformat für monatliche Aufbewahrungsrichtlinie.
|
|
retentionScheduleFormatType
|
RetentionScheduleFormat
|
Formattyp des Aufbewahrungszeitplans für die monatliche Aufbewahrungsrichtlinie.
|
|
retentionScheduleWeekly
|
WeeklyRetentionFormat
|
Wöchentliches Aufbewahrungsformat für monatliche Aufbewahrungsrichtlinie.
|
|
retentionTimes
|
string[]
(date-time)
|
Aufbewahrungszeiten der Aufbewahrungsrichtlinie.
|
MonthOfYear
Enumeration
| Wert |
Beschreibung |
|
Invalid
|
|
|
January
|
|
|
February
|
|
|
March
|
|
|
April
|
|
|
May
|
|
|
June
|
|
|
July
|
|
|
August
|
|
|
September
|
|
|
October
|
|
|
November
|
|
|
December
|
|
PolicyType
Enumeration
Typ des Sicherungsrichtlinientyps
| Wert |
Beschreibung |
|
Invalid
|
|
|
Full
|
|
|
Differential
|
|
|
Log
|
|
|
CopyOnlyFull
|
|
|
Incremental
|
|
|
SnapshotFull
|
|
|
SnapshotCopyOnlyFull
|
|
ProtectionPolicyResource
Objekt
Basisklasse für Sicherungsrichtlinie. Workloadspezifische Sicherungsrichtlinien werden von dieser Klasse abgeleitet.
| Name |
Typ |
Beschreibung |
|
eTag
|
string
|
Optionales ETag.
|
|
id
|
string
|
Vollqualifizierte Ressourcen-ID für die Ressource. Beispiel: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
location
|
string
|
Der geografische Standort, an dem sich die Ressource befindet
|
|
name
|
string
|
Der Name der Ressource
|
|
properties
|
ProtectionPolicy:
|
ProtectionPolicyResource Eigenschaften
|
|
systemData
|
systemData
|
Azure Resource Manager-Metadaten, die createdBy- und modifiedBy-Informationen enthalten.
|
|
tags
|
object
|
Ressourcenkennzeichnungen.
|
|
type
|
string
|
Der Typ der Ressource. Z. B. "Microsoft.Compute/virtualMachines" oder "Microsoft.Storage/storageAccounts"
|
RetentionDuration
Objekt
Aufbewahrungsdauer.
| Name |
Typ |
Beschreibung |
|
count
|
integer
(int32)
|
Anzahl der Dauertypen. Die Aufbewahrungsdauer wird durch die Zählung des Dauertyps Anzahl Mal abgerufen.
Wenn beispielsweise Count = 3 und DurationType = Wochen, die Aufbewahrungsdauer drei Wochen betragen.
|
|
durationType
|
RetentionDurationType
|
Aufbewahrungsdauertyp der Aufbewahrungsrichtlinie.
|
RetentionDurationType
Enumeration
Aufbewahrungsdauertyp der Aufbewahrungsrichtlinie.
| Wert |
Beschreibung |
|
Invalid
|
|
|
Days
|
|
|
Weeks
|
|
|
Months
|
|
|
Years
|
|
Enumeration
Formattyp des Aufbewahrungszeitplans für die monatliche Aufbewahrungsrichtlinie.
| Wert |
Beschreibung |
|
Invalid
|
|
|
Daily
|
|
|
Weekly
|
|
ScheduleRunType
Enumeration
Häufigkeit des Zeitplanvorgangs dieser Richtlinie.
| Wert |
Beschreibung |
|
Invalid
|
|
|
Daily
|
|
|
Weekly
|
|
|
Hourly
|
|
Settings
Objekt
Allgemeines Einstellungsfeld für die Sicherungsverwaltung
| Name |
Typ |
Beschreibung |
|
isCompression
|
boolean
|
Workloadkomprimierungskennzeichnung. Dies wurde hinzugefügt, damit "isSqlCompression" veraltet ist, sobald Clients ein Upgrade durchführen, um dieses Flag zu berücksichtigen.
|
|
issqlcompression
|
boolean
|
SQL-Komprimierungskennzeichnung
|
|
timeZone
|
string
|
Optionale TimeZone-Eingabe als Zeichenfolge. Beispiel: TimeZone = "Pacific Standard Time".
|
SimpleRetentionPolicy
Objekt
Einfache Richtlinienaufbewahrung.
| Name |
Typ |
Beschreibung |
|
retentionDuration
|
RetentionDuration
|
Aufbewahrungsdauer der Schutzrichtlinie.
|
|
retentionPolicyType
|
string:
SimpleRetentionPolicy
|
Diese Eigenschaft wird als Diskriminator für die Entscheidung der spezifischen Typen in der polymorphen Kette von Typen verwendet.
|
SimpleSchedulePolicy
Objekt
Einfacher Richtlinienzeitplan.
| Name |
Typ |
Beschreibung |
|
hourlySchedule
|
HourlySchedule
|
Stundenplan dieser Richtlinie
|
|
schedulePolicyType
|
string:
SimpleSchedulePolicy
|
Diese Eigenschaft wird als Diskriminator für die Entscheidung der spezifischen Typen in der polymorphen Kette von Typen verwendet.
|
|
scheduleRunDays
|
DayOfWeek[]
|
Liste der Wochentage, an denen dieser Zeitplan ausgeführt werden muss.
|
|
scheduleRunFrequency
|
ScheduleRunType
|
Häufigkeit des Zeitplanvorgangs dieser Richtlinie.
|
|
scheduleRunTimes
|
string[]
(date-time)
|
Liste der Tageszeiten, zu denen dieser Zeitplan ausgeführt werden muss.
|
|
scheduleWeeklyFrequency
|
integer
(int32)
|
Zu jeder Anzahl Wochen muss dieser Zeitplan ausgeführt werden.
|
SimpleSchedulePolicyV2
Objekt
Der V2-Richtlinienzeitplan für IaaS, der Stündliche Sicherungen unterstützt.
| Name |
Typ |
Beschreibung |
|
dailySchedule
|
DailySchedule
|
Täglicher Zeitplan dieser Richtlinie
|
|
hourlySchedule
|
HourlySchedule
|
Stundenplan dieser Richtlinie
|
|
schedulePolicyType
|
string:
SimpleSchedulePolicyV2
|
Diese Eigenschaft wird als Diskriminator für die Entscheidung der spezifischen Typen in der polymorphen Kette von Typen verwendet.
|
|
scheduleRunFrequency
|
ScheduleRunType
|
Häufigkeit des Zeitplanvorgangs dieser Richtlinie.
|
|
weeklySchedule
|
WeeklySchedule
|
Wöchentlicher Zeitplan dieser Richtlinie
|
SnapshotBackupAdditionalDetails
Objekt
Snapshot Backup verwandte Felder für WorkloadType SaPHanaSystem
| Name |
Typ |
Beschreibung |
|
instantRPDetails
|
string
|
|
|
instantRpRetentionRangeInDays
|
integer
(int32)
|
|
|
userAssignedManagedIdentityDetails
|
UserAssignedManagedIdentityDetails
|
Details zur vom Benutzer zugewiesenen verwalteten Identität
|
SubProtectionPolicy
Objekt
Richtlinie zum Unterschutz, die Zeitplan und Aufbewahrung umfasst
| Name |
Typ |
Beschreibung |
|
policyType
|
PolicyType
|
Typ des Sicherungsrichtlinientyps
|
|
retentionPolicy
|
RetentionPolicy:
|
Aufbewahrungsrichtlinie mit den Details zu Aufbewahrungsbereichen für Sicherungskopien.
|
|
schedulePolicy
|
SchedulePolicy:
|
Sicherungszeitplan, der als Teil der Sicherungsrichtlinie angegeben ist.
|
|
snapshotBackupAdditionalDetails
|
SnapshotBackupAdditionalDetails
|
Snapshot Backup verwandte Felder für WorkloadType SaPHanaSystem
|
|
tieringPolicy
|
<string,
TieringPolicy>
|
Ebenenrichtlinie zum automatischen Verschieben von RPs auf eine andere Ebene.
Key ist die Zielebene, die in recoveryPointTierType-Enumeration definiert ist.
Die Ebenenrichtlinie gibt die Kriterien an, die RP auf die Zielebene verschoben werden sollen.
|
systemData
Objekt
Metadaten zur Erstellung und letzten Änderung der Ressource.
| Name |
Typ |
Beschreibung |
|
createdAt
|
string
(date-time)
|
Der Zeitstempel der Ressourcenerstellung (UTC).
|
|
createdBy
|
string
|
Die Identität, die die Ressource erstellt hat.
|
|
createdByType
|
createdByType
|
Der Identitätstyp, der die Ressource erstellt hat.
|
|
lastModifiedAt
|
string
(date-time)
|
Der Zeitstempel der letzten Änderung der Ressource (UTC)
|
|
lastModifiedBy
|
string
|
Die Identität, die die Ressource zuletzt geändert hat.
|
|
lastModifiedByType
|
createdByType
|
Der Identitätstyp, der die Ressource zuletzt geändert hat.
|
TieringMode
Enumeration
Tiering-Modus zur Steuerung des automatischen Tierings von Wiederherstellungspunkten. Unterstützte Werte sind:
- TierRecommended: Stufen Sie alle Wiederherstellungspunkte, die empfohlen werden, gestuft zu werden
- TierAfter: Stufen Sie alle Wiederherstellungspunkte nach einem festen Zeitraum, wie unter "Duration + durationType" angegeben.
- DoNotTier: Keine Wiederherstellungspunkte stufen
| Wert |
Beschreibung |
|
Invalid
|
|
|
TierRecommended
|
|
|
TierAfter
|
|
|
DoNotTier
|
|
TieringPolicy
Objekt
Ebenenrichtlinie für eine Zielebene.
Wenn die Richtlinie für eine bestimmte Zielebene nicht angegeben ist, behält der Dienst die vorhandene konfigurierte Tieringrichtlinie für diese Ebene bei.
| Name |
Typ |
Beschreibung |
|
duration
|
integer
(int32)
|
Anzahl der Tage/Wochen/Monate/Jahre, um Sicherungen in der aktuellen Ebene vor der Leiste beizubehalten.
Wird nur verwendet, wenn "TieringMode" auf "TierAfter" festgelegt ist
|
|
durationType
|
RetentionDurationType
|
Aufbewahrungsdauertyp: Tage/Wochen/Monate/Jahre Wird nur verwendet, wenn TieringMode auf "TierAfter" festgelegt ist
|
|
tieringMode
|
TieringMode
|
Tiering-Modus zur Steuerung des automatischen Tierings von Wiederherstellungspunkten. Unterstützte Werte sind:
- TierRecommended: Stufen Sie alle Wiederherstellungspunkte, die empfohlen werden, gestuft zu werden
- TierAfter: Stufen Sie alle Wiederherstellungspunkte nach einem festen Zeitraum, wie unter "Duration + durationType" angegeben.
- DoNotTier: Keine Wiederherstellungspunkte stufen
|
UserAssignedIdentityProperties
Objekt
Vom Benutzer zugewiesene Eigenschaften für verwaltete Identitäten
| Name |
Typ |
Beschreibung |
|
clientId
|
string
|
Die Client-ID der zugewiesenen Identität.
|
|
principalId
|
string
|
Die Prinzipal-ID der zugewiesenen Identität.
|
UserAssignedManagedIdentityDetails
Objekt
Details zur vom Benutzer zugewiesenen verwalteten Identität
| Name |
Typ |
Beschreibung |
|
identityArmId
|
string
|
Die ARM-ID der zugewiesenen Identität.
|
|
identityName
|
string
|
Der Name der zugewiesenen Identität.
|
|
userAssignedIdentityProperties
|
UserAssignedIdentityProperties
|
Vom Benutzer zugewiesene Eigenschaften für verwaltete Identitäten
|
VaultRetentionPolicy
Objekt
Tresoraufbewahrungsrichtlinie für AzureFileShare
| Name |
Typ |
Beschreibung |
|
snapshotRetentionInDays
|
integer
(int32)
|
|
|
vaultRetention
|
RetentionPolicy:
|
Basisklasse für Aufbewahrungsrichtlinie.
|
Objekt
Wöchentliches Aufbewahrungsformat.
| Name |
Typ |
Beschreibung |
|
daysOfTheWeek
|
DayOfWeek[]
|
Liste der Wochentage.
|
|
weeksOfTheMonth
|
WeekOfMonth[]
|
Liste der Wochen des Monats.
|
WeeklyRetentionSchedule
Objekt
Wöchentlicher Aufbewahrungszeitplan.
| Name |
Typ |
Beschreibung |
|
daysOfTheWeek
|
DayOfWeek[]
|
Liste der Wochentage für wöchentliche Aufbewahrungsrichtlinien.
|
|
retentionDuration
|
RetentionDuration
|
Aufbewahrungsdauer der Aufbewahrungsrichtlinie.
|
|
retentionTimes
|
string[]
(date-time)
|
Aufbewahrungszeiten der Aufbewahrungsrichtlinie.
|
WeeklySchedule
Objekt
| Name |
Typ |
Beschreibung |
|
scheduleRunDays
|
DayOfWeek[]
|
|
|
scheduleRunTimes
|
string[]
(date-time)
|
Liste der Tageszeiten, zu denen dieser Zeitplan ausgeführt werden muss.
|
WeekOfMonth
Enumeration
| Wert |
Beschreibung |
|
First
|
|
|
Second
|
|
|
Third
|
|
|
Fourth
|
|
|
Last
|
|
|
Invalid
|
|
WorkloadType
Enumeration
Art der Arbeitsauslastung für die Sicherungsverwaltung
| Wert |
Beschreibung |
|
Invalid
|
|
|
VM
|
|
|
FileFolder
|
|
|
AzureSqlDb
|
|
|
SQLDB
|
|
|
Exchange
|
|
|
Sharepoint
|
|
|
VMwareVM
|
|
|
SystemState
|
|
|
Client
|
|
|
GenericDataSource
|
|
|
SQLDataBase
|
|
|
AzureFileShare
|
|
|
SAPHanaDatabase
|
|
|
SAPAseDatabase
|
|
|
SAPHanaDBInstance
|
|
YearlyRetentionSchedule
Objekt
Jährlicher Aufbewahrungszeitplan.
| Name |
Typ |
Beschreibung |
|
monthsOfYear
|
MonthOfYear[]
|
Liste der Monate des Jahres der jährlichen Aufbewahrungsrichtlinie.
|
|
retentionDuration
|
RetentionDuration
|
Aufbewahrungsdauer der Aufbewahrungsrichtlinie.
|
|
retentionScheduleDaily
|
DailyRetentionFormat
|
Tägliches Aufbewahrungsformat für jährliche Aufbewahrungsrichtlinie.
|
|
retentionScheduleFormatType
|
RetentionScheduleFormat
|
Aufbewahrungszeitplanformat für jährliche Aufbewahrungsrichtlinie.
|
|
retentionScheduleWeekly
|
WeeklyRetentionFormat
|
Wöchentliches Aufbewahrungsformat für jährliche Aufbewahrungsrichtlinie.
|
|
retentionTimes
|
string[]
(date-time)
|
Aufbewahrungszeiten der Aufbewahrungsrichtlinie.
|