Yedekleme ilkesi oluşturur veya değiştirir. Bu zaman uyumsuz bir işlemdir. İşlemin durumu GetPolicyOperationResult API'sini kullanarak getirilebilir.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupPolicies/{policyName}?api-version=2023-02-01
URI Parametreleri
Name |
İçinde |
Gerekli |
Tür |
Description |
policyName
|
path |
True
|
string
|
Oluşturulacak yedekleme ilkesi.
|
resourceGroupName
|
path |
True
|
string
|
Kurtarma hizmetleri kasasının bulunduğu kaynak grubunun adı.
|
subscriptionId
|
path |
True
|
string
|
Abonelik kimliği.
|
vaultName
|
path |
True
|
string
|
Kurtarma hizmetleri kasasının adı.
|
api-version
|
query |
True
|
string
|
İstemci Api Sürümü.
|
İstek Gövdesi
Name |
Tür |
Description |
eTag
|
string
|
İsteğe bağlı ETag.
|
location
|
string
|
Kaynak konumu.
|
properties
|
ProtectionPolicy:
|
ProtectionPolicyResource özellikleri
|
tags
|
object
|
Kaynak etiketleri.
|
Yanıtlar
Name |
Tür |
Description |
200 OK
|
ProtectionPolicyResource
|
Tamam
|
202 Accepted
|
|
Kabul edildi
|
Other Status Codes
|
CloudError
|
İşlemin neden başarısız olduğunu açıklayan hata yanıtı.
|
Güvenlik
azure_auth
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
kullanıcı hesabınızın kimliğine bürünme.
|
Örnekler
Create or Update Daily Azure Storage Protection Policy
Sample Request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/dailyPolicy2?api-version=2023-02-01
{
"properties": {
"backupManagementType": "AzureStorage",
"workLoadType": "AzureFileShare",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": [
"2021-09-29T08:00:00.000Z"
]
},
"timeZone": "UTC",
"retentionPolicy": {
"retentionPolicyType": "LongTermRetentionPolicy",
"dailySchedule": {
"retentionTimes": [
"2021-09-29T08:00:00.000Z"
],
"retentionDuration": {
"count": 5,
"durationType": "Days"
}
},
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionTimes": [
"2021-09-29T08:00:00.000Z"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
}
},
"monthlySchedule": {
"retentionScheduleFormatType": "Weekly",
"retentionScheduleDaily": null,
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-09-29T08:00:00.000Z"
],
"retentionDuration": {
"count": 60,
"durationType": "Months"
}
},
"yearlySchedule": {
"retentionScheduleFormatType": "Weekly",
"monthsOfYear": [
"January"
],
"retentionScheduleDaily": null,
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-09-29T08:00:00.000Z"
],
"retentionDuration": {
"count": 10,
"durationType": "Years"
}
}
}
}
}
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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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")
.withRegion((String) null)
.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="00000000-0000-0000-0000-000000000000",
)
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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a498cae6d1a93f4c33073f0747b93b22815c09b7/specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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("<subscription-id>", 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{
RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](5),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
},
RetentionTimes: []*time.Time{
to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T08:00:00.000Z"); return t }())},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T08:00:00.000Z"); return t }())},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T08:00:00.000Z"); return t }())},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T08:00:00.000Z"); return t }())},
},
},
SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeDaily),
ScheduleRunTimes: []*time.Time{
to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T08:00:00.000Z"); return t }())},
},
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.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{
// RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
// DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](5),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T08:00:00Z"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T08:00:00Z"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T08:00:00Z"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T08:00:00Z"); return t}())},
// },
// },
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
// ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeDaily),
// ScheduleRunTimes: []*time.Time{
// to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T08:00:00Z"); return t}())},
// 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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureStorage/ProtectionPolicies_CreateOrUpdate_Daily.json
*/
async function createOrUpdateDailyAzureStorageProtectionPolicy() {
const subscriptionId =
process.env["RECOVERYSERVICESBACKUP_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const vaultName = "swaggertestvault";
const resourceGroupName = process.env["RECOVERYSERVICESBACKUP_RESOURCE_GROUP"] || "SwaggerTestRg";
const policyName = "dailyPolicy2";
const parameters = {
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" },
retentionScheduleDaily: {},
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" },
retentionScheduleDaily: {},
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",
},
};
const credential = new DefaultAzureCredential();
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
vaultName,
resourceGroupName,
policyName,
parameters
);
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
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.RecoveryServicesBackup;
using Azure.ResourceManager.RecoveryServicesBackup.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureStorage/ProtectionPolicies_CreateOrUpdate_Daily.json
// this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "SwaggerTestRg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this BackupProtectionPolicyResource
string vaultName = "swaggertestvault";
BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName);
// invoke the operation
string policyName = "dailyPolicy2";
BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder"))
{
Properties = new FileShareProtectionPolicy()
{
WorkLoadType = BackupWorkloadType.AzureFileShare,
SchedulePolicy = new SimpleSchedulePolicy()
{
ScheduleRunFrequency = ScheduleRunType.Daily,
ScheduleRunTimes =
{
DateTimeOffset.Parse("2021-09-29T08:00:00.000Z")
},
},
RetentionPolicy = new LongTermRetentionPolicy()
{
DailySchedule = new DailyRetentionSchedule()
{
RetentionTimes =
{
DateTimeOffset.Parse("2021-09-29T08:00:00.000Z")
},
RetentionDuration = new RetentionDuration()
{
Count = 5,
DurationType = RetentionDurationType.Days,
},
},
WeeklySchedule = new WeeklyRetentionSchedule()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday
},
RetentionTimes =
{
DateTimeOffset.Parse("2021-09-29T08:00:00.000Z")
},
RetentionDuration = new RetentionDuration()
{
Count = 12,
DurationType = RetentionDurationType.Weeks,
},
},
MonthlySchedule = new MonthlyRetentionSchedule()
{
RetentionScheduleFormatType = RetentionScheduleFormat.Weekly,
RetentionScheduleWeekly = new WeeklyRetentionFormat()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday
},
WeeksOfTheMonth =
{
BackupWeekOfMonth.First
},
},
RetentionTimes =
{
DateTimeOffset.Parse("2021-09-29T08:00:00.000Z")
},
RetentionDuration = new RetentionDuration()
{
Count = 60,
DurationType = RetentionDurationType.Months,
},
},
YearlySchedule = new YearlyRetentionSchedule()
{
RetentionScheduleFormatType = RetentionScheduleFormat.Weekly,
MonthsOfYear =
{
BackupMonthOfYear.January
},
RetentionScheduleWeekly = new WeeklyRetentionFormat()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday
},
WeeksOfTheMonth =
{
BackupWeekOfMonth.First
},
},
RetentionTimes =
{
DateTimeOffset.Parse("2021-09-29T08:00:00.000Z")
},
RetentionDuration = new RetentionDuration()
{
Count = 10,
DurationType = RetentionDurationType.Years,
},
},
},
TimeZone = "UTC",
},
};
ArmOperation<BackupProtectionPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data);
BackupProtectionPolicyResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BackupProtectionPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/dailyPolicy2",
"name": "dailyPolicy2",
"type": "Microsoft.RecoveryServices/vaults/backupPolicies",
"properties": {
"backupManagementType": "AzureStorage",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": [
"2021-09-29T08:00:00Z"
],
"scheduleWeeklyFrequency": 0
},
"retentionPolicy": {
"retentionPolicyType": "LongTermRetentionPolicy",
"dailySchedule": {
"retentionTimes": [
"2021-09-29T08:00:00Z"
],
"retentionDuration": {
"count": 5,
"durationType": "Days"
}
},
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionTimes": [
"2021-09-29T08:00:00Z"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
}
},
"monthlySchedule": {
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-09-29T08:00:00Z"
],
"retentionDuration": {
"count": 60,
"durationType": "Months"
}
},
"yearlySchedule": {
"retentionScheduleFormatType": "Weekly",
"monthsOfYear": [
"January"
],
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-09-29T08:00:00Z"
],
"retentionDuration": {
"count": 10,
"durationType": "Years"
}
}
},
"timeZone": "UTC",
"protectedItemsCount": 0
}
}
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
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
Retry-After: 60
Create or Update Enhanced Azure Vm Protection Policy with daily backup
Sample Request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/v2-daily-sample?api-version=2023-02-01
{
"properties": {
"backupManagementType": "AzureIaasVM",
"timeZone": "India Standard Time",
"instantRpRetentionRangeInDays": 30,
"policyType": "V2",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicyV2",
"scheduleRunFrequency": "Daily",
"dailySchedule": {
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
]
}
},
"retentionPolicy": {
"retentionPolicyType": "LongTermRetentionPolicy",
"dailySchedule": {
"retentionDuration": {
"count": 180,
"durationType": "Days"
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
},
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
},
"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"
]
},
"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"
]
}
}
}
}
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.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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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")
.withRegion((String) null)
.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))
.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="00000000-0000-0000-0000-000000000000",
)
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",
},
"timeZone": "India Standard Time",
}
},
)
print(response)
# x-ms-original-file: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a498cae6d1a93f4c33073f0747b93b22815c09b7/specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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("<subscription-id>", 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{
RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](180),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
},
RetentionTimes: []*time.Time{
to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t }())},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t }())},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t }())},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t }())},
},
},
SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicyV2{
SchedulePolicyType: to.Ptr("SimpleSchedulePolicyV2"),
DailySchedule: &armrecoveryservicesbackup.DailySchedule{
ScheduleRunTimes: []*time.Time{
to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t }())},
},
ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeDaily),
},
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.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"),
// ProtectedItemsCount: to.Ptr[int32](0),
// InstantRpRetentionRangeInDays: to.Ptr[int32](30),
// PolicyType: to.Ptr(armrecoveryservicesbackup.IAASVMPolicyTypeV2),
// RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
// RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
// DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](180),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t}())},
// },
// },
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicyV2{
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicyV2"),
// DailySchedule: &armrecoveryservicesbackup.DailySchedule{
// ScheduleRunTimes: []*time.Time{
// to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t}())},
// },
// ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeDaily),
// },
// 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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureIaasVm/V2Policy/IaaS_v2_daily.json
*/
async function createOrUpdateEnhancedAzureVMProtectionPolicyWithDailyBackup() {
const subscriptionId =
process.env["RECOVERYSERVICESBACKUP_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const vaultName = "NetSDKTestRsVault";
const resourceGroupName = process.env["RECOVERYSERVICESBACKUP_RESOURCE_GROUP"] || "SwaggerTestRg";
const policyName = "v2-daily-sample";
const parameters = {
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" },
retentionScheduleDaily: {},
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" },
retentionScheduleDaily: {},
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",
},
timeZone: "India Standard Time",
},
};
const credential = new DefaultAzureCredential();
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
vaultName,
resourceGroupName,
policyName,
parameters
);
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
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.RecoveryServicesBackup;
using Azure.ResourceManager.RecoveryServicesBackup.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureIaasVm/V2Policy/IaaS_v2_daily.json
// this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "SwaggerTestRg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this BackupProtectionPolicyResource
string vaultName = "NetSDKTestRsVault";
BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName);
// invoke the operation
string policyName = "v2-daily-sample";
BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder"))
{
Properties = new IaasVmProtectionPolicy()
{
SchedulePolicy = new SimpleSchedulePolicyV2()
{
ScheduleRunFrequency = ScheduleRunType.Daily,
ScheduleRunTimes =
{
DateTimeOffset.Parse("2018-01-24T10:00:00Z")
},
},
RetentionPolicy = new LongTermRetentionPolicy()
{
DailySchedule = new DailyRetentionSchedule()
{
RetentionTimes =
{
DateTimeOffset.Parse("2021-12-17T08:00:00+00:00")
},
RetentionDuration = new RetentionDuration()
{
Count = 180,
DurationType = RetentionDurationType.Days,
},
},
WeeklySchedule = new WeeklyRetentionSchedule()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday
},
RetentionTimes =
{
DateTimeOffset.Parse("2021-12-17T08:00:00+00:00")
},
RetentionDuration = new RetentionDuration()
{
Count = 12,
DurationType = RetentionDurationType.Weeks,
},
},
MonthlySchedule = new MonthlyRetentionSchedule()
{
RetentionScheduleFormatType = RetentionScheduleFormat.Weekly,
RetentionScheduleWeekly = new WeeklyRetentionFormat()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday
},
WeeksOfTheMonth =
{
BackupWeekOfMonth.First
},
},
RetentionTimes =
{
DateTimeOffset.Parse("2021-12-17T08:00:00+00:00")
},
RetentionDuration = new RetentionDuration()
{
Count = 60,
DurationType = RetentionDurationType.Months,
},
},
YearlySchedule = new YearlyRetentionSchedule()
{
RetentionScheduleFormatType = RetentionScheduleFormat.Weekly,
MonthsOfYear =
{
BackupMonthOfYear.January
},
RetentionScheduleWeekly = new WeeklyRetentionFormat()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday
},
WeeksOfTheMonth =
{
BackupWeekOfMonth.First
},
},
RetentionTimes =
{
DateTimeOffset.Parse("2021-12-17T08:00:00+00:00")
},
RetentionDuration = new RetentionDuration()
{
Count = 10,
DurationType = RetentionDurationType.Years,
},
},
},
InstantRPRetentionRangeInDays = 30,
TimeZone = "India Standard Time",
PolicyType = IaasVmPolicyType.V2,
},
};
ArmOperation<BackupProtectionPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data);
BackupProtectionPolicyResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BackupProtectionPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/v2-daily-sample",
"name": "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"
},
"timeZone": "India Standard Time"
},
"type": "Microsoft.RecoveryServices/vaults/backupPolicies"
}
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
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
Retry-After: 60
Create or Update Enhanced Azure Vm Protection Policy with Hourly backup
Sample Request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/v2-daily-sample?api-version=2023-02-01
{
"properties": {
"backupManagementType": "AzureIaasVM",
"timeZone": "India Standard Time",
"instantRpRetentionRangeInDays": 30,
"policyType": "V2",
"schedulePolicy": {
"hourlySchedule": {
"interval": 4,
"scheduleWindowDuration": 16,
"scheduleWindowStartTime": "2021-12-17T08:00:00Z"
},
"schedulePolicyType": "SimpleSchedulePolicyV2",
"scheduleRunFrequency": "Hourly"
},
"retentionPolicy": {
"retentionPolicyType": "LongTermRetentionPolicy",
"dailySchedule": {
"retentionDuration": {
"count": 180,
"durationType": "Days"
},
"retentionTimes": [
"2021-12-17T08:00:00+00:00"
]
},
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
},
"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"
]
},
"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"
]
}
}
}
}
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.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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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")
.withRegion((String) null)
.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))
.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="00000000-0000-0000-0000-000000000000",
)
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",
},
"timeZone": "India Standard Time",
}
},
)
print(response)
# x-ms-original-file: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a498cae6d1a93f4c33073f0747b93b22815c09b7/specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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("<subscription-id>", 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{
RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](180),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
},
RetentionTimes: []*time.Time{
to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t }())},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t }())},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t }())},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t }())},
},
},
SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicyV2{
SchedulePolicyType: to.Ptr("SimpleSchedulePolicyV2"),
HourlySchedule: &armrecoveryservicesbackup.HourlySchedule{
Interval: to.Ptr[int32](4),
ScheduleWindowDuration: to.Ptr[int32](16),
ScheduleWindowStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00Z"); return t }()),
},
ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeHourly),
},
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.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"),
// ProtectedItemsCount: to.Ptr[int32](0),
// InstantRpRetentionRangeInDays: to.Ptr[int32](30),
// PolicyType: to.Ptr(armrecoveryservicesbackup.IAASVMPolicyTypeV2),
// RetentionPolicy: &armrecoveryservicesbackup.LongTermRetentionPolicy{
// RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
// DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](180),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00+00:00"); return t}())},
// },
// },
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicyV2{
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicyV2"),
// HourlySchedule: &armrecoveryservicesbackup.HourlySchedule{
// Interval: to.Ptr[int32](4),
// ScheduleWindowDuration: to.Ptr[int32](16),
// ScheduleWindowStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-17T08:00:00Z"); return t}()),
// },
// ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeHourly),
// },
// 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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureIaasVm/V2Policy/IaaS_v2_hourly.json
*/
async function createOrUpdateEnhancedAzureVMProtectionPolicyWithHourlyBackup() {
const subscriptionId =
process.env["RECOVERYSERVICESBACKUP_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const vaultName = "NetSDKTestRsVault";
const resourceGroupName = process.env["RECOVERYSERVICESBACKUP_RESOURCE_GROUP"] || "SwaggerTestRg";
const policyName = "v2-daily-sample";
const parameters = {
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" },
retentionScheduleDaily: {},
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" },
retentionScheduleDaily: {},
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",
},
timeZone: "India Standard Time",
},
};
const credential = new DefaultAzureCredential();
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
vaultName,
resourceGroupName,
policyName,
parameters
);
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
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.RecoveryServicesBackup;
using Azure.ResourceManager.RecoveryServicesBackup.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureIaasVm/V2Policy/IaaS_v2_hourly.json
// this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "SwaggerTestRg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this BackupProtectionPolicyResource
string vaultName = "NetSDKTestRsVault";
BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName);
// invoke the operation
string policyName = "v2-daily-sample";
BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder"))
{
Properties = new IaasVmProtectionPolicy()
{
SchedulePolicy = new SimpleSchedulePolicyV2()
{
ScheduleRunFrequency = ScheduleRunType.Hourly,
HourlySchedule = new BackupHourlySchedule()
{
Interval = 4,
ScheduleWindowStartOn = DateTimeOffset.Parse("2021-12-17T08:00:00Z"),
ScheduleWindowDuration = 16,
},
},
RetentionPolicy = new LongTermRetentionPolicy()
{
DailySchedule = new DailyRetentionSchedule()
{
RetentionTimes =
{
DateTimeOffset.Parse("2021-12-17T08:00:00+00:00")
},
RetentionDuration = new RetentionDuration()
{
Count = 180,
DurationType = RetentionDurationType.Days,
},
},
WeeklySchedule = new WeeklyRetentionSchedule()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday
},
RetentionTimes =
{
DateTimeOffset.Parse("2021-12-17T08:00:00+00:00")
},
RetentionDuration = new RetentionDuration()
{
Count = 12,
DurationType = RetentionDurationType.Weeks,
},
},
MonthlySchedule = new MonthlyRetentionSchedule()
{
RetentionScheduleFormatType = RetentionScheduleFormat.Weekly,
RetentionScheduleWeekly = new WeeklyRetentionFormat()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday
},
WeeksOfTheMonth =
{
BackupWeekOfMonth.First
},
},
RetentionTimes =
{
DateTimeOffset.Parse("2021-12-17T08:00:00+00:00")
},
RetentionDuration = new RetentionDuration()
{
Count = 60,
DurationType = RetentionDurationType.Months,
},
},
YearlySchedule = new YearlyRetentionSchedule()
{
RetentionScheduleFormatType = RetentionScheduleFormat.Weekly,
MonthsOfYear =
{
BackupMonthOfYear.January
},
RetentionScheduleWeekly = new WeeklyRetentionFormat()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday
},
WeeksOfTheMonth =
{
BackupWeekOfMonth.First
},
},
RetentionTimes =
{
DateTimeOffset.Parse("2021-12-17T08:00:00+00:00")
},
RetentionDuration = new RetentionDuration()
{
Count = 10,
DurationType = RetentionDurationType.Years,
},
},
},
InstantRPRetentionRangeInDays = 30,
TimeZone = "India Standard Time",
PolicyType = IaasVmPolicyType.V2,
},
};
ArmOperation<BackupProtectionPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data);
BackupProtectionPolicyResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BackupProtectionPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/v2-daily-sample",
"name": "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"
},
"timeZone": "India Standard Time"
},
"type": "Microsoft.RecoveryServices/vaults/backupPolicies"
}
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
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
Retry-After: 60
Create or Update Full Azure Vm Protection Policy
Sample Request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1?api-version=2023-02-01
{
"properties": {
"backupManagementType": "AzureIaasVM",
"timeZone": "Pacific Standard Time",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Weekly",
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
],
"scheduleRunDays": [
"Monday",
"Wednesday",
"Thursday"
]
},
"retentionPolicy": {
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Monday",
"Wednesday",
"Thursday"
],
"retentionTimes": [
"2018-01-24T10:00:00Z"
],
"retentionDuration": {
"count": 1,
"durationType": "Weeks"
}
},
"monthlySchedule": {
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Wednesday",
"Thursday"
],
"weeksOfTheMonth": [
"First",
"Third"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
],
"retentionDuration": {
"count": 2,
"durationType": "Months"
}
},
"yearlySchedule": {
"retentionScheduleFormatType": "Weekly",
"monthsOfYear": [
"February",
"November"
],
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Monday",
"Thursday"
],
"weeksOfTheMonth": [
"Fourth"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
],
"retentionDuration": {
"count": 4,
"durationType": "Years"
}
}
}
}
}
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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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")
.withRegion((String) null)
.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
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="00000000-0000-0000-0000-000000000000",
)
response = client.protection_policies.create_or_update(
vault_name="NetSDKTestRsVault",
resource_group_name="SwaggerTestRg",
policy_name="testPolicy1",
parameters={
"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",
}
},
)
print(response)
# x-ms-original-file: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureIaasVm/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/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a498cae6d1a93f4c33073f0747b93b22815c09b7/specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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("<subscription-id>", 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{
RetentionPolicyType: to.Ptr("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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t }())},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t }())},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t }())},
},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t }())},
},
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.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{
// RetentionPolicyType: to.Ptr("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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t}())},
// },
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t}())},
// 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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Complex.json
*/
async function createOrUpdateFullAzureVMProtectionPolicy() {
const subscriptionId =
process.env["RECOVERYSERVICESBACKUP_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const vaultName = "NetSDKTestRsVault";
const resourceGroupName = process.env["RECOVERYSERVICESBACKUP_RESOURCE_GROUP"] || "SwaggerTestRg";
const policyName = "testPolicy1";
const parameters = {
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",
},
};
const credential = new DefaultAzureCredential();
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
vaultName,
resourceGroupName,
policyName,
parameters
);
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
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.RecoveryServicesBackup;
using Azure.ResourceManager.RecoveryServicesBackup.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Complex.json
// this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "SwaggerTestRg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this BackupProtectionPolicyResource
string vaultName = "NetSDKTestRsVault";
BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName);
// invoke the operation
string policyName = "testPolicy1";
BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder"))
{
Properties = new IaasVmProtectionPolicy()
{
SchedulePolicy = new SimpleSchedulePolicy()
{
ScheduleRunFrequency = ScheduleRunType.Weekly,
ScheduleRunDays =
{
BackupDayOfWeek.Monday,BackupDayOfWeek.Wednesday,BackupDayOfWeek.Thursday
},
ScheduleRunTimes =
{
DateTimeOffset.Parse("2018-01-24T10:00:00Z")
},
},
RetentionPolicy = new LongTermRetentionPolicy()
{
WeeklySchedule = new WeeklyRetentionSchedule()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Monday,BackupDayOfWeek.Wednesday,BackupDayOfWeek.Thursday
},
RetentionTimes =
{
DateTimeOffset.Parse("2018-01-24T10:00:00Z")
},
RetentionDuration = new RetentionDuration()
{
Count = 1,
DurationType = RetentionDurationType.Weeks,
},
},
MonthlySchedule = new MonthlyRetentionSchedule()
{
RetentionScheduleFormatType = RetentionScheduleFormat.Weekly,
RetentionScheduleWeekly = new WeeklyRetentionFormat()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Wednesday,BackupDayOfWeek.Thursday
},
WeeksOfTheMonth =
{
BackupWeekOfMonth.First,BackupWeekOfMonth.Third
},
},
RetentionTimes =
{
DateTimeOffset.Parse("2018-01-24T10:00:00Z")
},
RetentionDuration = new RetentionDuration()
{
Count = 2,
DurationType = RetentionDurationType.Months,
},
},
YearlySchedule = new YearlyRetentionSchedule()
{
RetentionScheduleFormatType = RetentionScheduleFormat.Weekly,
MonthsOfYear =
{
BackupMonthOfYear.February,BackupMonthOfYear.November
},
RetentionScheduleWeekly = new WeeklyRetentionFormat()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Monday,BackupDayOfWeek.Thursday
},
WeeksOfTheMonth =
{
BackupWeekOfMonth.Fourth
},
},
RetentionTimes =
{
DateTimeOffset.Parse("2018-01-24T10:00:00Z")
},
RetentionDuration = new RetentionDuration()
{
Count = 4,
DurationType = RetentionDurationType.Years,
},
},
},
TimeZone = "Pacific Standard Time",
},
};
ArmOperation<BackupProtectionPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data);
BackupProtectionPolicyResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BackupProtectionPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1",
"name": "testPolicy1",
"type": "Microsoft.RecoveryServices/vaults/backupPolicies",
"properties": {
"backupManagementType": "AzureIaasVM",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Weekly",
"scheduleRunDays": [
"Monday",
"Wednesday",
"Thursday"
],
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
],
"scheduleWeeklyFrequency": 0
},
"retentionPolicy": {
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Monday",
"Wednesday",
"Thursday"
],
"retentionTimes": [
"2018-01-24T10:00:00Z"
],
"retentionDuration": {
"count": 1,
"durationType": "Weeks"
}
},
"monthlySchedule": {
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Wednesday",
"Thursday"
],
"weeksOfTheMonth": [
"First",
"Third"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
],
"retentionDuration": {
"count": 2,
"durationType": "Months"
}
},
"yearlySchedule": {
"retentionScheduleFormatType": "Weekly",
"monthsOfYear": [
"February",
"November"
],
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Monday",
"Thursday"
],
"weeksOfTheMonth": [
"Fourth"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
],
"retentionDuration": {
"count": 4,
"durationType": "Years"
}
}
},
"timeZone": "Pacific Standard Time",
"protectedItemsCount": 0
}
}
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
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
Retry-After: 60
Create or Update Full Azure Workload Protection Policy
Sample Request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1?api-version=2023-02-01
{
"properties": {
"backupManagementType": "AzureWorkload",
"workLoadType": "SQLDataBase",
"settings": {
"timeZone": "Pacific Standard Time",
"issqlcompression": false
},
"subProtectionPolicy": [
{
"policyType": "Full",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Weekly",
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
],
"scheduleRunDays": [
"Sunday",
"Tuesday"
]
},
"retentionPolicy": {
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday",
"Tuesday"
],
"retentionTimes": [
"2018-01-24T10:00:00Z"
],
"retentionDuration": {
"count": 2,
"durationType": "Weeks"
}
},
"monthlySchedule": {
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"Second"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
],
"retentionDuration": {
"count": 1,
"durationType": "Months"
}
},
"yearlySchedule": {
"retentionScheduleFormatType": "Weekly",
"monthsOfYear": [
"January",
"June",
"December"
],
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"Last"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
],
"retentionDuration": {
"count": 1,
"durationType": "Years"
}
}
}
},
{
"policyType": "Differential",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Weekly",
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
],
"scheduleRunDays": [
"Friday"
]
},
"retentionPolicy": {
"retentionPolicyType": "SimpleRetentionPolicy",
"retentionDuration": {
"count": 8,
"durationType": "Days"
}
}
},
{
"policyType": "Log",
"schedulePolicy": {
"schedulePolicyType": "LogSchedulePolicy",
"scheduleFrequencyInMins": 60
},
"retentionPolicy": {
"retentionPolicyType": "SimpleRetentionPolicy",
"retentionDuration": {
"count": 7,
"durationType": "Days"
}
}
}
]
}
}
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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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")
.withRegion((String) null)
.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
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/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a498cae6d1a93f4c33073f0747b93b22815c09b7/specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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("<subscription-id>", 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{
RetentionPolicyType: to.Ptr("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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t }())},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t }())},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t }())},
},
},
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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t }())},
},
},
{
PolicyType: to.Ptr(armrecoveryservicesbackup.PolicyTypeDifferential),
RetentionPolicy: &armrecoveryservicesbackup.SimpleRetentionPolicy{
RetentionPolicyType: to.Ptr("SimpleRetentionPolicy"),
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](8),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
},
},
SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
ScheduleRunDays: []*armrecoveryservicesbackup.DayOfWeek{
to.Ptr(armrecoveryservicesbackup.DayOfWeekFriday)},
ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeWeekly),
ScheduleRunTimes: []*time.Time{
to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t }())},
},
},
{
PolicyType: to.Ptr(armrecoveryservicesbackup.PolicyTypeLog),
RetentionPolicy: &armrecoveryservicesbackup.SimpleRetentionPolicy{
RetentionPolicyType: to.Ptr("SimpleRetentionPolicy"),
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](7),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
},
},
SchedulePolicy: &armrecoveryservicesbackup.LogSchedulePolicy{
SchedulePolicyType: to.Ptr("LogSchedulePolicy"),
ScheduleFrequencyInMins: to.Ptr[int32](60),
},
}},
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.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{
// RetentionPolicyType: to.Ptr("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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t}())},
// },
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t}())},
// ScheduleWeeklyFrequency: to.Ptr[int32](0),
// },
// },
// {
// PolicyType: to.Ptr(armrecoveryservicesbackup.PolicyTypeDifferential),
// RetentionPolicy: &armrecoveryservicesbackup.SimpleRetentionPolicy{
// RetentionPolicyType: to.Ptr("SimpleRetentionPolicy"),
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](8),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// },
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
// ScheduleRunDays: []*armrecoveryservicesbackup.DayOfWeek{
// to.Ptr(armrecoveryservicesbackup.DayOfWeekFriday)},
// ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeWeekly),
// ScheduleRunTimes: []*time.Time{
// to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T10:00:00Z"); return t}())},
// ScheduleWeeklyFrequency: to.Ptr[int32](0),
// },
// },
// {
// PolicyType: to.Ptr(armrecoveryservicesbackup.PolicyTypeLog),
// RetentionPolicy: &armrecoveryservicesbackup.SimpleRetentionPolicy{
// RetentionPolicyType: to.Ptr("SimpleRetentionPolicy"),
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](7),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// },
// SchedulePolicy: &armrecoveryservicesbackup.LogSchedulePolicy{
// SchedulePolicyType: to.Ptr("LogSchedulePolicy"),
// ScheduleFrequencyInMins: to.Ptr[int32](60),
// },
// }},
// 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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureWorkload/ProtectionPolicies_CreateOrUpdate_Complex.json
*/
async function createOrUpdateFullAzureWorkloadProtectionPolicy() {
const subscriptionId =
process.env["RECOVERYSERVICESBACKUP_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const vaultName = "NetSDKTestRsVault";
const resourceGroupName = process.env["RECOVERYSERVICESBACKUP_RESOURCE_GROUP"] || "SwaggerTestRg";
const policyName = "testPolicy1";
const 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: [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",
},
};
const credential = new DefaultAzureCredential();
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
vaultName,
resourceGroupName,
policyName,
parameters
);
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
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.RecoveryServicesBackup;
using Azure.ResourceManager.RecoveryServicesBackup.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureWorkload/ProtectionPolicies_CreateOrUpdate_Complex.json
// this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "SwaggerTestRg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this BackupProtectionPolicyResource
string vaultName = "NetSDKTestRsVault";
BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName);
// invoke the operation
string policyName = "testPolicy1";
BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder"))
{
Properties = new VmWorkloadProtectionPolicy()
{
WorkLoadType = BackupWorkloadType.SqlDatabase,
Settings = new BackupCommonSettings()
{
TimeZone = "Pacific Standard Time",
IsSqlCompression = false,
},
SubProtectionPolicy =
{
new SubProtectionPolicy()
{
PolicyType = SubProtectionPolicyType.Full,
SchedulePolicy = new SimpleSchedulePolicy()
{
ScheduleRunFrequency = ScheduleRunType.Weekly,
ScheduleRunDays =
{
BackupDayOfWeek.Sunday,BackupDayOfWeek.Tuesday
},
ScheduleRunTimes =
{
DateTimeOffset.Parse("2018-01-24T10:00:00Z")
},
},
RetentionPolicy = new LongTermRetentionPolicy()
{
WeeklySchedule = new WeeklyRetentionSchedule()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday,BackupDayOfWeek.Tuesday
},
RetentionTimes =
{
DateTimeOffset.Parse("2018-01-24T10:00:00Z")
},
RetentionDuration = new RetentionDuration()
{
Count = 2,
DurationType = RetentionDurationType.Weeks,
},
},
MonthlySchedule = new MonthlyRetentionSchedule()
{
RetentionScheduleFormatType = RetentionScheduleFormat.Weekly,
RetentionScheduleWeekly = new WeeklyRetentionFormat()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday
},
WeeksOfTheMonth =
{
BackupWeekOfMonth.Second
},
},
RetentionTimes =
{
DateTimeOffset.Parse("2018-01-24T10:00:00Z")
},
RetentionDuration = new RetentionDuration()
{
Count = 1,
DurationType = RetentionDurationType.Months,
},
},
YearlySchedule = new YearlyRetentionSchedule()
{
RetentionScheduleFormatType = RetentionScheduleFormat.Weekly,
MonthsOfYear =
{
BackupMonthOfYear.January,BackupMonthOfYear.June,BackupMonthOfYear.December
},
RetentionScheduleWeekly = new WeeklyRetentionFormat()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday
},
WeeksOfTheMonth =
{
BackupWeekOfMonth.Last
},
},
RetentionTimes =
{
DateTimeOffset.Parse("2018-01-24T10:00:00Z")
},
RetentionDuration = new RetentionDuration()
{
Count = 1,
DurationType = RetentionDurationType.Years,
},
},
},
},new SubProtectionPolicy()
{
PolicyType = SubProtectionPolicyType.Differential,
SchedulePolicy = new SimpleSchedulePolicy()
{
ScheduleRunFrequency = ScheduleRunType.Weekly,
ScheduleRunDays =
{
BackupDayOfWeek.Friday
},
ScheduleRunTimes =
{
DateTimeOffset.Parse("2018-01-24T10:00:00Z")
},
},
RetentionPolicy = new SimpleRetentionPolicy()
{
RetentionDuration = new RetentionDuration()
{
Count = 8,
DurationType = RetentionDurationType.Days,
},
},
},new SubProtectionPolicy()
{
PolicyType = SubProtectionPolicyType.Log,
SchedulePolicy = new LogSchedulePolicy()
{
ScheduleFrequencyInMins = 60,
},
RetentionPolicy = new SimpleRetentionPolicy()
{
RetentionDuration = new RetentionDuration()
{
Count = 7,
DurationType = RetentionDurationType.Days,
},
},
}
},
},
};
ArmOperation<BackupProtectionPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data);
BackupProtectionPolicyResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BackupProtectionPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1",
"name": "testPolicy1",
"type": "Microsoft.RecoveryServices/vaults/backupPolicies",
"properties": {
"backupManagementType": "AzureWorkload",
"workLoadType": "SQLDataBase",
"settings": {
"timeZone": "Pacific Standard Time",
"issqlcompression": false
},
"subProtectionPolicy": [
{
"policyType": "Full",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Weekly",
"scheduleRunDays": [
"Sunday",
"Tuesday"
],
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
],
"scheduleWeeklyFrequency": 0
},
"retentionPolicy": {
"retentionPolicyType": "LongTermRetentionPolicy",
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday",
"Tuesday"
],
"retentionTimes": [
"2018-01-24T10:00:00Z"
],
"retentionDuration": {
"count": 2,
"durationType": "Weeks"
}
},
"monthlySchedule": {
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"Second"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
],
"retentionDuration": {
"count": 1,
"durationType": "Months"
}
},
"yearlySchedule": {
"retentionScheduleFormatType": "Weekly",
"monthsOfYear": [
"January",
"June",
"December"
],
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"Last"
]
},
"retentionTimes": [
"2018-01-24T10:00:00Z"
],
"retentionDuration": {
"count": 1,
"durationType": "Years"
}
}
}
},
{
"policyType": "Differential",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Weekly",
"scheduleRunDays": [
"Friday"
],
"scheduleRunTimes": [
"2018-01-24T10:00:00Z"
],
"scheduleWeeklyFrequency": 0
},
"retentionPolicy": {
"retentionPolicyType": "SimpleRetentionPolicy",
"retentionDuration": {
"count": 8,
"durationType": "Days"
}
}
},
{
"policyType": "Log",
"schedulePolicy": {
"schedulePolicyType": "LogSchedulePolicy",
"scheduleFrequencyInMins": 60
},
"retentionPolicy": {
"retentionPolicyType": "SimpleRetentionPolicy",
"retentionDuration": {
"count": 7,
"durationType": "Days"
}
}
}
],
"protectedItemsCount": 0
}
}
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
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
Retry-After: 60
Create or Update Hourly Azure Storage Protection Policy
Sample Request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/newPolicy2?api-version=2023-02-01
{
"properties": {
"backupManagementType": "AzureStorage",
"workLoadType": "AzureFileShare",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Hourly",
"hourlySchedule": {
"interval": 4,
"scheduleWindowStartTime": "2021-09-29T08:00:00.000Z",
"scheduleWindowDuration": 12
}
},
"timeZone": "UTC",
"retentionPolicy": {
"retentionPolicyType": "LongTermRetentionPolicy",
"dailySchedule": {
"retentionTimes": null,
"retentionDuration": {
"count": 5,
"durationType": "Days"
}
},
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionTimes": null,
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
}
},
"monthlySchedule": {
"retentionScheduleFormatType": "Weekly",
"retentionScheduleDaily": null,
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": null,
"retentionDuration": {
"count": 60,
"durationType": "Months"
}
},
"yearlySchedule": {
"retentionScheduleFormatType": "Weekly",
"monthsOfYear": [
"January"
],
"retentionScheduleDaily": null,
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": null,
"retentionDuration": {
"count": 10,
"durationType": "Years"
}
}
}
}
}
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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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")
.withRegion((String) null)
.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="00000000-0000-0000-0000-000000000000",
)
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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a498cae6d1a93f4c33073f0747b93b22815c09b7/specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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("<subscription-id>", 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{
RetentionPolicyType: to.Ptr("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)},
},
},
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{
SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
HourlySchedule: &armrecoveryservicesbackup.HourlySchedule{
Interval: to.Ptr[int32](4),
ScheduleWindowDuration: to.Ptr[int32](12),
ScheduleWindowStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T08:00:00.000Z"); return t }()),
},
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.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{
// RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
// DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](5),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T20:00:00Z"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T20:00:00Z"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T20:00:00Z"); return t}())},
// },
// 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(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T20:00:00Z"); return t}())},
// },
// },
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
// HourlySchedule: &armrecoveryservicesbackup.HourlySchedule{
// Interval: to.Ptr[int32](4),
// ScheduleWindowDuration: to.Ptr[int32](12),
// ScheduleWindowStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-29T08:00:00Z"); return t}()),
// },
// 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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureStorage/ProtectionPolicies_CreateOrUpdate_Hourly.json
*/
async function createOrUpdateHourlyAzureStorageProtectionPolicy() {
const subscriptionId =
process.env["RECOVERYSERVICESBACKUP_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const vaultName = "swaggertestvault";
const resourceGroupName = process.env["RECOVERYSERVICESBACKUP_RESOURCE_GROUP"] || "SwaggerTestRg";
const policyName = "newPolicy2";
const parameters = {
properties: {
backupManagementType: "AzureStorage",
retentionPolicy: {
dailySchedule: {
retentionDuration: { count: 5, durationType: "Days" },
retentionTimes: [],
},
monthlySchedule: {
retentionDuration: { count: 60, durationType: "Months" },
retentionScheduleDaily: {},
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: {
daysOfTheWeek: ["Sunday"],
weeksOfTheMonth: ["First"],
},
retentionTimes: [],
},
retentionPolicyType: "LongTermRetentionPolicy",
weeklySchedule: {
daysOfTheWeek: ["Sunday"],
retentionDuration: { count: 12, durationType: "Weeks" },
retentionTimes: [],
},
yearlySchedule: {
monthsOfYear: ["January"],
retentionDuration: { count: 10, durationType: "Years" },
retentionScheduleDaily: {},
retentionScheduleFormatType: "Weekly",
retentionScheduleWeekly: {
daysOfTheWeek: ["Sunday"],
weeksOfTheMonth: ["First"],
},
retentionTimes: [],
},
},
schedulePolicy: {
hourlySchedule: {
interval: 4,
scheduleWindowDuration: 12,
scheduleWindowStartTime: new Date("2021-09-29T08:00:00.000Z"),
},
schedulePolicyType: "SimpleSchedulePolicy",
scheduleRunFrequency: "Hourly",
},
timeZone: "UTC",
workLoadType: "AzureFileShare",
},
};
const credential = new DefaultAzureCredential();
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
vaultName,
resourceGroupName,
policyName,
parameters
);
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
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.RecoveryServicesBackup;
using Azure.ResourceManager.RecoveryServicesBackup.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureStorage/ProtectionPolicies_CreateOrUpdate_Hourly.json
// this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "SwaggerTestRg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this BackupProtectionPolicyResource
string vaultName = "swaggertestvault";
BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName);
// invoke the operation
string policyName = "newPolicy2";
BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder"))
{
Properties = new FileShareProtectionPolicy()
{
WorkLoadType = BackupWorkloadType.AzureFileShare,
SchedulePolicy = new SimpleSchedulePolicy()
{
ScheduleRunFrequency = ScheduleRunType.Hourly,
HourlySchedule = new BackupHourlySchedule()
{
Interval = 4,
ScheduleWindowStartOn = DateTimeOffset.Parse("2021-09-29T08:00:00.000Z"),
ScheduleWindowDuration = 12,
},
},
RetentionPolicy = new LongTermRetentionPolicy()
{
DailySchedule = new DailyRetentionSchedule()
{
RetentionTimes =
{
},
RetentionDuration = new RetentionDuration()
{
Count = 5,
DurationType = RetentionDurationType.Days,
},
},
WeeklySchedule = new WeeklyRetentionSchedule()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday
},
RetentionTimes =
{
},
RetentionDuration = new RetentionDuration()
{
Count = 12,
DurationType = RetentionDurationType.Weeks,
},
},
MonthlySchedule = new MonthlyRetentionSchedule()
{
RetentionScheduleFormatType = RetentionScheduleFormat.Weekly,
RetentionScheduleWeekly = new WeeklyRetentionFormat()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday
},
WeeksOfTheMonth =
{
BackupWeekOfMonth.First
},
},
RetentionTimes =
{
},
RetentionDuration = new RetentionDuration()
{
Count = 60,
DurationType = RetentionDurationType.Months,
},
},
YearlySchedule = new YearlyRetentionSchedule()
{
RetentionScheduleFormatType = RetentionScheduleFormat.Weekly,
MonthsOfYear =
{
BackupMonthOfYear.January
},
RetentionScheduleWeekly = new WeeklyRetentionFormat()
{
DaysOfTheWeek =
{
BackupDayOfWeek.Sunday
},
WeeksOfTheMonth =
{
BackupWeekOfMonth.First
},
},
RetentionTimes =
{
},
RetentionDuration = new RetentionDuration()
{
Count = 10,
DurationType = RetentionDurationType.Years,
},
},
},
TimeZone = "UTC",
},
};
ArmOperation<BackupProtectionPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data);
BackupProtectionPolicyResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BackupProtectionPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/swaggertestvault/backupPolicies/newPolicy2",
"name": "newPolicy2",
"type": "Microsoft.RecoveryServices/vaults/backupPolicies",
"properties": {
"backupManagementType": "AzureStorage",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Hourly",
"hourlySchedule": {
"interval": 4,
"scheduleWindowStartTime": "2021-09-29T08:00:00Z",
"scheduleWindowDuration": 12
},
"scheduleWeeklyFrequency": 0
},
"retentionPolicy": {
"retentionPolicyType": "LongTermRetentionPolicy",
"dailySchedule": {
"retentionTimes": [
"2021-09-29T20:00:00Z"
],
"retentionDuration": {
"count": 5,
"durationType": "Days"
}
},
"weeklySchedule": {
"daysOfTheWeek": [
"Sunday"
],
"retentionTimes": [
"2021-09-29T20:00:00Z"
],
"retentionDuration": {
"count": 12,
"durationType": "Weeks"
}
},
"monthlySchedule": {
"retentionScheduleFormatType": "Weekly",
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-09-29T20:00:00Z"
],
"retentionDuration": {
"count": 60,
"durationType": "Months"
}
},
"yearlySchedule": {
"retentionScheduleFormatType": "Weekly",
"monthsOfYear": [
"January"
],
"retentionScheduleWeekly": {
"daysOfTheWeek": [
"Sunday"
],
"weeksOfTheMonth": [
"First"
]
},
"retentionTimes": [
"2021-09-29T20:00:00Z"
],
"retentionDuration": {
"count": 10,
"durationType": "Years"
}
}
},
"timeZone": "UTC",
"protectedItemsCount": 0
}
}
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
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
Retry-After: 60
Create or Update Simple Azure Vm Protection Policy
Sample Request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1?api-version=2023-02-01
{
"properties": {
"backupManagementType": "AzureIaasVM",
"timeZone": "Pacific Standard Time",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": [
"2018-01-24T02:00:00Z"
]
},
"retentionPolicy": {
"retentionPolicyType": "LongTermRetentionPolicy",
"dailySchedule": {
"retentionTimes": [
"2018-01-24T02:00:00Z"
],
"retentionDuration": {
"count": 1,
"durationType": "Days"
}
}
}
}
}
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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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")
.withRegion((String) null)
.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="00000000-0000-0000-0000-000000000000",
)
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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a498cae6d1a93f4c33073f0747b93b22815c09b7/specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/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("<subscription-id>", 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{
RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
Count: to.Ptr[int32](1),
DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
},
RetentionTimes: []*time.Time{
to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T02:00:00Z"); return t }())},
},
},
SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeDaily),
ScheduleRunTimes: []*time.Time{
to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T02:00:00Z"); return t }())},
},
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.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{
// RetentionPolicyType: to.Ptr("LongTermRetentionPolicy"),
// DailySchedule: &armrecoveryservicesbackup.DailyRetentionSchedule{
// RetentionDuration: &armrecoveryservicesbackup.RetentionDuration{
// Count: to.Ptr[int32](1),
// DurationType: to.Ptr(armrecoveryservicesbackup.RetentionDurationTypeDays),
// },
// RetentionTimes: []*time.Time{
// to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T02:00:00Z"); return t}())},
// },
// },
// SchedulePolicy: &armrecoveryservicesbackup.SimpleSchedulePolicy{
// SchedulePolicyType: to.Ptr("SimpleSchedulePolicy"),
// ScheduleRunFrequency: to.Ptr(armrecoveryservicesbackup.ScheduleRunTypeDaily),
// ScheduleRunTimes: []*time.Time{
// to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-24T02:00:00Z"); return t}())},
// 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: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Simple.json
*/
async function createOrUpdateSimpleAzureVMProtectionPolicy() {
const subscriptionId =
process.env["RECOVERYSERVICESBACKUP_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const vaultName = "NetSDKTestRsVault";
const resourceGroupName = process.env["RECOVERYSERVICESBACKUP_RESOURCE_GROUP"] || "SwaggerTestRg";
const policyName = "testPolicy1";
const parameters = {
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",
},
};
const credential = new DefaultAzureCredential();
const client = new RecoveryServicesBackupClient(credential, subscriptionId);
const result = await client.protectionPolicies.createOrUpdate(
vaultName,
resourceGroupName,
policyName,
parameters
);
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
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.RecoveryServicesBackup;
using Azure.ResourceManager.RecoveryServicesBackup.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-02-01/examples/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Simple.json
// this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "SwaggerTestRg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this BackupProtectionPolicyResource
string vaultName = "NetSDKTestRsVault";
BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName);
// invoke the operation
string policyName = "testPolicy1";
BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder"))
{
Properties = new IaasVmProtectionPolicy()
{
SchedulePolicy = new SimpleSchedulePolicy()
{
ScheduleRunFrequency = ScheduleRunType.Daily,
ScheduleRunTimes =
{
DateTimeOffset.Parse("2018-01-24T02:00:00Z")
},
},
RetentionPolicy = new LongTermRetentionPolicy()
{
DailySchedule = new DailyRetentionSchedule()
{
RetentionTimes =
{
DateTimeOffset.Parse("2018-01-24T02:00:00Z")
},
RetentionDuration = new RetentionDuration()
{
Count = 1,
DurationType = RetentionDurationType.Days,
},
},
},
TimeZone = "Pacific Standard Time",
},
};
ArmOperation<BackupProtectionPolicyResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data);
BackupProtectionPolicyResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BackupProtectionPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/testPolicy1",
"name": "testPolicy1",
"type": "Microsoft.RecoveryServices/vaults/backupPolicies",
"properties": {
"backupManagementType": "AzureIaasVM",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": [
"2018-01-24T02:00:00Z"
],
"scheduleWeeklyFrequency": 0
},
"retentionPolicy": {
"retentionPolicyType": "LongTermRetentionPolicy",
"dailySchedule": {
"retentionTimes": [
"2018-01-24T02:00:00Z"
],
"retentionDuration": {
"count": 1,
"durationType": "Days"
}
}
},
"timeZone": "Pacific Standard Time",
"protectedItemsCount": 0
}
}
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
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
Retry-After: 60
Tanımlar
AzureFileShareProtectionPolicy
AzureStorage yedekleme ilkesi.
Name |
Tür |
Description |
backupManagementType
|
string:
AzureStorage
|
Bu özellik, türlerin polimorfik zincirindeki belirli türleri karar vermek için ayrımcı olarak kullanılır.
|
protectedItemsCount
|
integer
|
Bu ilkeyle ilişkili öğe sayısı.
|
resourceGuardOperationRequests
|
string[]
|
ResourceGuard İşlem İstekleri
|
retentionPolicy
|
RetentionPolicy:
|
Yedek kopya bekletme aralıklarıyla ilgili ayrıntıları içeren bekletme ilkesi.
|
schedulePolicy
|
SchedulePolicy:
|
Yedekleme ilkesinin bir parçası olarak belirtilen yedekleme zamanlaması.
|
timeZone
|
string
|
Dize olarak TimeZone isteğe bağlı girişi. Örneğin: TimeZone = "Pasifik Standart Saati".
|
workLoadType
|
WorkloadType
|
Yedekleme yönetimi için iş yükü türü
|
AzureIaaSVMProtectionPolicy
IaaS VM iş yüküne özgü yedekleme ilkesi.
Name |
Tür |
Description |
backupManagementType
|
string:
AzureIaasVM
|
Bu özellik, türlerin polimorfik zincirindeki belirli türleri karar vermek için ayrımcı olarak kullanılır.
|
instantRPDetails
|
InstantRPAdditionalDetails
|
|
instantRpRetentionRangeInDays
|
integer
|
Gün olarak anlık RP bekletme ilkesi aralığı
|
policyType
|
IAASVMPolicyType
|
|
protectedItemsCount
|
integer
|
Bu ilkeyle ilişkili öğe sayısı.
|
resourceGuardOperationRequests
|
string[]
|
ResourceGuard İşlem İstekleri
|
retentionPolicy
|
RetentionPolicy:
|
Yedek kopya bekletme aralıklarıyla ilgili ayrıntıları içeren bekletme ilkesi.
|
schedulePolicy
|
SchedulePolicy:
|
Yedekleme ilkesinin bir parçası olarak belirtilen yedekleme zamanlaması.
|
tieringPolicy
|
<string,
TieringPolicy>
|
RP'leri otomatik olarak başka bir katman Anahtarına taşımak için katmanlama ilkesi, RecoveryPointTierType sabit listesinde tanımlanan Hedef Katman'dır.
Katmanlama ilkesi, RP'yi hedef katmana taşıma ölçütlerini belirtir.
|
timeZone
|
string
|
Dize olarak TimeZone isteğe bağlı girişi. Örneğin: TimeZone = "Pasifik Standart Saati".
|
AzureSqlProtectionPolicy
İş yüküne özgü yedekleme ilkesini Azure SQL.
Name |
Tür |
Description |
backupManagementType
|
string:
AzureSql
|
Bu özellik, türlerin polimorfik zincirindeki belirli türleri karar vermek için ayrımcı olarak kullanılır.
|
protectedItemsCount
|
integer
|
Bu ilkeyle ilişkili öğe sayısı.
|
resourceGuardOperationRequests
|
string[]
|
ResourceGuard İşlem İstekleri
|
retentionPolicy
|
RetentionPolicy:
|
Bekletme ilkesi ayrıntıları.
|
AzureVmWorkloadProtectionPolicy
Azure VM (Mercury) iş yüküne özgü yedekleme ilkesi.
Name |
Tür |
Description |
backupManagementType
|
string:
AzureWorkload
|
Bu özellik, türlerin polimorfik zincirindeki belirli türleri karar vermek için ayrımcı olarak kullanılır.
|
makePolicyConsistent
|
boolean
|
İlke tutarsızlığını düzeltme
|
protectedItemsCount
|
integer
|
Bu ilkeyle ilişkili öğe sayısı.
|
resourceGuardOperationRequests
|
string[]
|
ResourceGuard İşlem İstekleri
|
settings
|
Settings
|
Yedekleme yönetimi için yaygın ayarlar
|
subProtectionPolicy
|
SubProtectionPolicy[]
|
Zamanlama ve saklamayı içeren alt koruma ilkelerinin listesi
|
workLoadType
|
WorkloadType
|
Yedekleme yönetimi için iş yükü türü
|
CloudError
Container Instance hizmetinden bir hata yanıtı.
CloudErrorBody
Container Instance hizmetinden bir hata yanıtı.
Name |
Tür |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
Hata ek bilgileri.
|
code
|
string
|
Hatanın tanımlayıcısı. Kodlar sabittir ve program aracılığıyla kullanılması amaçlanmıştır.
|
details
|
CloudErrorBody[]
|
Hatayla ilgili ek ayrıntıların listesi.
|
message
|
string
|
Hatayı açıklayan ve kullanıcı arabiriminde görüntülenmeye uygun olması amaçlanan bir ileti.
|
target
|
string
|
Belirli bir hatanın hedefi. Örneğin, özelliğin adı hatalı.
|
Günlük saklama biçimi.
Name |
Tür |
Description |
daysOfTheMonth
|
Day[]
|
Ayın günlerinin listesi.
|
DailyRetentionSchedule
Günlük saklama zamanlaması.
Name |
Tür |
Description |
retentionDuration
|
RetentionDuration
|
Bekletme İlkesinin bekletme süresi.
|
retentionTimes
|
string[]
|
Bekletme ilkesinin saklama süreleri.
|
DailySchedule
Name |
Tür |
Description |
scheduleRunTimes
|
string[]
|
Bu zamanlamanın çalıştırılması gereken günün saatlerinin listesi.
|
Day
Haftanın günü.
Name |
Tür |
Description |
date
|
integer
|
Ayın tarihi
|
isLast
|
boolean
|
Tarihin ayın son tarihi olup olmadığı
|
DayOfWeek
Name |
Tür |
Description |
Friday
|
string
|
|
Monday
|
string
|
|
Saturday
|
string
|
|
Sunday
|
string
|
|
Thursday
|
string
|
|
Tuesday
|
string
|
|
Wednesday
|
string
|
|
ErrorAdditionalInfo
Kaynak yönetimi hatası ek bilgileri.
Name |
Tür |
Description |
info
|
object
|
Ek bilgiler.
|
type
|
string
|
Ek bilgi türü.
|
GenericProtectionPolicy
Azure VM (Mercury) iş yüküne özgü yedekleme ilkesi.
Name |
Tür |
Description |
backupManagementType
|
string:
GenericProtectionPolicy
|
Bu özellik, türlerin polimorfik zincirindeki belirli türleri karar vermek için ayrımcı olarak kullanılır.
|
fabricName
|
string
|
Bu ilkenin dokusunun adı.
|
protectedItemsCount
|
integer
|
Bu ilkeyle ilişkili öğe sayısı.
|
resourceGuardOperationRequests
|
string[]
|
ResourceGuard İşlem İstekleri
|
subProtectionPolicy
|
SubProtectionPolicy[]
|
Zamanlama ve saklamayı içeren alt koruma ilkelerinin listesi
|
timeZone
|
string
|
Dize olarak TimeZone isteğe bağlı girişi. Örneğin: TimeZone = "Pasifik Standart Saati".
|
HourlySchedule
Name |
Tür |
Description |
interval
|
integer
|
Yedeklemenin tetiklenmesi gereken aralık. Saatlik değer 6/4/8/12 olabilir
|
scheduleWindowDuration
|
integer
|
Yedekleme penceresinin süresini belirtmek için
|
scheduleWindowStartTime
|
string
|
Yedekleme penceresinin başlangıç saatini belirtmek için
|
IAASVMPolicyType
Name |
Tür |
Description |
Invalid
|
string
|
|
V1
|
string
|
|
V2
|
string
|
|
InstantRPAdditionalDetails
Name |
Tür |
Description |
azureBackupRGNamePrefix
|
string
|
|
azureBackupRGNameSuffix
|
string
|
|
LogSchedulePolicy
Günlük ilkesi zamanlaması.
Name |
Tür |
Description |
scheduleFrequencyInMins
|
integer
|
Bu ilkenin günlük zamanlama işleminin dakika cinsinden sıklığı.
|
schedulePolicyType
|
string:
LogSchedulePolicy
|
Bu özellik, türlerin polimorfik zincirindeki belirli türleri karar vermek için ayrımcı olarak kullanılır.
|
LongTermRetentionPolicy
Uzun süreli saklama ilkesi.
LongTermSchedulePolicy
Uzun vadeli ilke zamanlaması.
Name |
Tür |
Description |
schedulePolicyType
|
string:
LongTermSchedulePolicy
|
Bu özellik, türlerin polimorfik zincirindeki belirli türleri karar vermek için ayrımcı olarak kullanılır.
|
MabProtectionPolicy
Mab kapsayıcıya özgü yedekleme ilkesi.
Name |
Tür |
Description |
backupManagementType
|
string:
MAB
|
Bu özellik, türlerin polimorfik zincirindeki belirli türleri karar vermek için ayrımcı olarak kullanılır.
|
protectedItemsCount
|
integer
|
Bu ilkeyle ilişkili öğe sayısı.
|
resourceGuardOperationRequests
|
string[]
|
ResourceGuard İşlem İstekleri
|
retentionPolicy
|
RetentionPolicy:
|
Bekletme ilkesi ayrıntıları.
|
schedulePolicy
|
SchedulePolicy:
|
Yedekleme ilkesinin yedekleme zamanlaması.
|
MonthlyRetentionSchedule
Aylık saklama zamanlaması.
Name |
Tür |
Description |
retentionDuration
|
RetentionDuration
|
Bekletme İlkesinin bekletme süresi.
|
retentionScheduleDaily
|
DailyRetentionFormat
|
Aylık saklama ilkesi için günlük saklama biçimi.
|
retentionScheduleFormatType
|
RetentionScheduleFormat
|
Aylık bekletme ilkesi için bekletme zamanlaması biçim türü.
|
retentionScheduleWeekly
|
WeeklyRetentionFormat
|
Aylık saklama ilkesi için haftalık saklama biçimi.
|
retentionTimes
|
string[]
|
Bekletme ilkesinin saklama süreleri.
|
MonthOfYear
Yıllık saklama ilkesinin ayların listesi.
Name |
Tür |
Description |
April
|
string
|
|
August
|
string
|
|
December
|
string
|
|
February
|
string
|
|
Invalid
|
string
|
|
January
|
string
|
|
July
|
string
|
|
June
|
string
|
|
March
|
string
|
|
May
|
string
|
|
November
|
string
|
|
October
|
string
|
|
September
|
string
|
|
PolicyType
Yedekleme ilkesi türü
Name |
Tür |
Description |
CopyOnlyFull
|
string
|
|
Differential
|
string
|
|
Full
|
string
|
|
Incremental
|
string
|
|
Invalid
|
string
|
|
Log
|
string
|
|
SnapshotCopyOnlyFull
|
string
|
|
SnapshotFull
|
string
|
|
ProtectionPolicyResource
Yedekleme ilkesi için temel sınıf. İş yüküne özgü yedekleme ilkeleri bu sınıftan türetilir.
Name |
Tür |
Description |
eTag
|
string
|
İsteğe bağlı ETag.
|
id
|
string
|
Kaynak Kimliği, kaynağın tam yolunu temsil eder.
|
location
|
string
|
Kaynak konumu.
|
name
|
string
|
Kaynakla ilişkili kaynak adı.
|
properties
|
ProtectionPolicy:
|
ProtectionPolicyResource özellikleri
|
tags
|
object
|
Kaynak etiketleri.
|
type
|
string
|
Kaynak türü Ad Alanı/ResourceType/ResourceType/... formunun tam yolunu temsil eder.
|
RetentionDuration
Bekletme süresi.
Name |
Tür |
Description |
count
|
integer
|
Süre türlerinin sayısı. Saklama süresi, süre türü Sayma süreleri sayılarak elde edilir.
Örneğin, Count = 3 ve DurationType = Weeks olduğunda bekletme süresi üç hafta olur.
|
durationType
|
RetentionDurationType
|
Bekletme ilkesi saklama süresi türü.
|
RetentionDurationType
Bekletme süresi türü: günler/haftalar/aylar/yıllar Yalnızca TieringMode TierAfter olarak ayarlandığında kullanılır
Name |
Tür |
Description |
Days
|
string
|
|
Invalid
|
string
|
|
Months
|
string
|
|
Weeks
|
string
|
|
Years
|
string
|
|
Aylık bekletme ilkesi için bekletme zamanlaması biçim türü.
Name |
Tür |
Description |
Daily
|
string
|
|
Invalid
|
string
|
|
Weekly
|
string
|
|
ScheduleRunType
Bu ilkenin zamanlama işleminin sıklığı.
Name |
Tür |
Description |
Daily
|
string
|
|
Hourly
|
string
|
|
Invalid
|
string
|
|
Weekly
|
string
|
|
Settings
Yedekleme yönetimi için ortak ayarlar alanı
Name |
Tür |
Description |
isCompression
|
boolean
|
İş yükü sıkıştırma bayrağı. İstemciler bu bayrağı dikkate alacak şekilde yükseltildiğinde 'isSqlCompression' kullanım dışı bırakılacak şekilde eklendi.
|
issqlcompression
|
boolean
|
SQL sıkıştırma bayrağı
|
timeZone
|
string
|
Dize olarak TimeZone isteğe bağlı girişi. Örneğin: TimeZone = "Pasifik Standart Saati".
|
SimpleRetentionPolicy
Basit ilke saklama.
Name |
Tür |
Description |
retentionDuration
|
RetentionDuration
|
Koruma ilkesinin saklama süresi.
|
retentionPolicyType
|
string:
SimpleRetentionPolicy
|
Bu özellik, türlerin polimorfik zincirindeki belirli türleri karar vermek için ayrımcı olarak kullanılır.
|
SimpleSchedulePolicy
Basit ilke zamanlaması.
Name |
Tür |
Description |
hourlySchedule
|
HourlySchedule
|
Bu İlkenin Saatlik Zamanlaması
|
schedulePolicyType
|
string:
SimpleSchedulePolicy
|
Bu özellik, türlerin polimorfik zincirindeki belirli türleri karar vermek için ayrımcı olarak kullanılır.
|
scheduleRunDays
|
DayOfWeek[]
|
Bu zamanlamanın çalıştırılması gereken haftanın günlerinin listesi.
|
scheduleRunFrequency
|
ScheduleRunType
|
Bu ilkenin zamanlama işleminin sıklığı.
|
scheduleRunTimes
|
string[]
|
Bu zamanlamanın çalıştırılması gereken günün saatlerinin listesi.
|
scheduleWeeklyFrequency
|
integer
|
Haftalarca bu zamanlamanın çalıştırılması gerekir.
|
SimpleSchedulePolicyV2
Saatlik yedeklemeleri destekleyen IaaS için V2 ilke zamanlaması.
Name |
Tür |
Description |
dailySchedule
|
DailySchedule
|
Bu ilkenin günlük zamanlaması
|
hourlySchedule
|
HourlySchedule
|
bu ilkenin saatlik zamanlaması
|
schedulePolicyType
|
string:
SimpleSchedulePolicyV2
|
Bu özellik, türlerin polimorfik zincirindeki belirli türleri karar vermek için ayrımcı olarak kullanılır.
|
scheduleRunFrequency
|
ScheduleRunType
|
Bu ilkenin zamanlama işleminin sıklığı.
|
weeklySchedule
|
WeeklySchedule
|
Bu ilkenin haftalık zamanlaması
|
SubProtectionPolicy
Zamanlama ve saklamayı içeren alt koruma ilkesi
Name |
Tür |
Description |
policyType
|
PolicyType
|
Yedekleme ilkesi türü
|
retentionPolicy
|
RetentionPolicy:
|
Yedek kopya bekletme aralıklarıyla ilgili ayrıntıları içeren bekletme ilkesi.
|
schedulePolicy
|
SchedulePolicy:
|
Yedekleme ilkesinin bir parçası olarak belirtilen yedekleme zamanlaması.
|
tieringPolicy
|
<string,
TieringPolicy>
|
RP'leri otomatik olarak başka bir katmana taşımak için katmanlama ilkesi.
Anahtar, RecoveryPointTierType sabit listesinde tanımlanan Hedef Katmandır.
Katmanlama ilkesi, RP'yi hedef katmana taşıma ölçütlerini belirtir.
|
TieringMode
Kurtarma noktalarının otomatik katmanlamasını denetlemek için Katmanlama Modu. Desteklenen değerler şunlardır:
- TierRecommended: Katmanlanması önerilen tüm kurtarma noktalarını katmanla
- TierAfter: Aşağıdaki duration + durationType içinde belirtildiği gibi, sabit bir dönemden sonra tüm kurtarma noktalarını katmanla.
- DoNotTier: Hiçbir kurtarma noktasını katmanlamayın
Name |
Tür |
Description |
DoNotTier
|
string
|
|
Invalid
|
string
|
|
TierAfter
|
string
|
|
TierRecommended
|
string
|
|
TieringPolicy
Hedef katman için Katmanlama İlkesi.
İlke belirli bir hedef katman için belirtilmezse, hizmet söz konusu katman için mevcut yapılandırılmış katmanlama ilkesini korur
Name |
Tür |
Description |
duration
|
integer
|
Katmanlamadan önce yedeklemelerin geçerli katmanda tutulacak gün/hafta/ay/yıl sayısı.
Yalnızca TieringMode TierAfter olarak ayarlandığında kullanılır
|
durationType
|
RetentionDurationType
|
Bekletme süresi türü: günler/haftalar/aylar/yıllar Yalnızca TieringMode TierAfter olarak ayarlandığında kullanılır
|
tieringMode
|
TieringMode
|
Kurtarma noktalarının otomatik katmanlamasını denetlemek için Katmanlama Modu. Desteklenen değerler şunlardır:
- TierRecommended: Katmanlanması önerilen tüm kurtarma noktalarını katmanla
- TierAfter: Aşağıdaki duration + durationType içinde belirtildiği gibi, sabit bir dönemden sonra tüm kurtarma noktalarını katmanla.
- DoNotTier: Hiçbir kurtarma noktasını katmanlamayın
|
Haftalık saklama biçimi.
Name |
Tür |
Description |
daysOfTheWeek
|
DayOfWeek[]
|
Haftanın günlerinin listesi.
|
weeksOfTheMonth
|
WeekOfMonth[]
|
Ayın haftalarının listesi.
|
WeeklyRetentionSchedule
Haftalık saklama zamanlaması.
Name |
Tür |
Description |
daysOfTheWeek
|
DayOfWeek[]
|
Haftalık saklama ilkesi için haftanın günlerinin listesi.
|
retentionDuration
|
RetentionDuration
|
Bekletme İlkesinin bekletme süresi.
|
retentionTimes
|
string[]
|
Bekletme ilkesinin saklama süreleri.
|
WeeklySchedule
Name |
Tür |
Description |
scheduleRunDays
|
DayOfWeek[]
|
|
scheduleRunTimes
|
string[]
|
Bu zamanlamanın çalıştırılması gereken günün saatlerinin listesi.
|
WeekOfMonth
Ayın haftalarının listesi.
Name |
Tür |
Description |
First
|
string
|
|
Fourth
|
string
|
|
Invalid
|
string
|
|
Last
|
string
|
|
Second
|
string
|
|
Third
|
string
|
|
WorkloadType
Yedekleme yönetimi için iş yükü türü
Name |
Tür |
Description |
AzureFileShare
|
string
|
|
AzureSqlDb
|
string
|
|
Client
|
string
|
|
Exchange
|
string
|
|
FileFolder
|
string
|
|
GenericDataSource
|
string
|
|
Invalid
|
string
|
|
SAPAseDatabase
|
string
|
|
SAPHanaDBInstance
|
string
|
|
SAPHanaDatabase
|
string
|
|
SQLDB
|
string
|
|
SQLDataBase
|
string
|
|
Sharepoint
|
string
|
|
SystemState
|
string
|
|
VM
|
string
|
|
VMwareVM
|
string
|
|
YearlyRetentionSchedule
Yıllık saklama zamanlaması.
Name |
Tür |
Description |
monthsOfYear
|
MonthOfYear[]
|
Yıllık saklama ilkesinin ayların listesi.
|
retentionDuration
|
RetentionDuration
|
Bekletme İlkesinin bekletme süresi.
|
retentionScheduleDaily
|
DailyRetentionFormat
|
Yıllık saklama ilkesi için günlük saklama biçimi.
|
retentionScheduleFormatType
|
RetentionScheduleFormat
|
Yıllık saklama ilkesi için bekletme zamanlaması biçimi.
|
retentionScheduleWeekly
|
WeeklyRetentionFormat
|
Yıllık saklama ilkesi için haftalık saklama biçimi.
|
retentionTimes
|
string[]
|
Bekletme ilkesinin saklama süreleri.
|