Skip to content

Commit 5f81534

Browse files
author
Nicholas King
committed
Added cmdlet to help create a database backup setting
1 parent 61ab1d6 commit 5f81534

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Management.Automation;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using Microsoft.Azure.Commands.ResourceManager.Common;
8+
using Microsoft.Azure.Management.WebSites.Models;
9+
10+
namespace Microsoft.Azure.Commands.WebApps.Cmdlets.BackupRestore
11+
{
12+
/// <summary>
13+
/// Modifies the automatic backup configuration for an Azure Web App
14+
/// </summary>
15+
[Cmdlet(VerbsCommon.New, "AzureRmWebAppDatabaseBackupSetting"), OutputType(typeof (DatabaseBackupSetting))]
16+
public class NewAzureRmWebAppDatabaseBackupSetting : AzureRMCmdlet
17+
{
18+
[Parameter(Position = 0, Mandatory = true, HelpMessage = "The name of the database.",
19+
ValueFromPipelineByPropertyName = true)]
20+
[ValidateNotNullOrEmpty]
21+
public string Name { get; set; }
22+
23+
[Parameter(Position = 1, Mandatory = true, HelpMessage = "The type of database, e.g. SqlAzure or MySql.",
24+
ValueFromPipelineByPropertyName = true)]
25+
[ValidateNotNullOrEmpty]
26+
public string DatabaseType { get; set; }
27+
28+
[Parameter(Position = 2, Mandatory = true, HelpMessage = "The database's connection string. If the restore should happen to a new database, the database name inside is the new one.",
29+
ValueFromPipelineByPropertyName = true)]
30+
[ValidateNotNullOrEmpty]
31+
public string ConnectionString { get; set; }
32+
33+
[Parameter(Position = 3, Mandatory = false, HelpMessage = "Contains a connection string name that is linked to the SiteConfig.ConnectionStrings. This is used during restore with overwrite connection strings options.",
34+
ValueFromPipelineByPropertyName = true)]
35+
public string ConnectionStringName { get; set; }
36+
37+
public override void ExecuteCmdlet()
38+
{
39+
DatabaseBackupSetting setting = new DatabaseBackupSetting()
40+
{
41+
Name = this.Name,
42+
DatabaseType = this.DatabaseType,
43+
ConnectionString = this.ConnectionString,
44+
ConnectionStringName = this.ConnectionStringName
45+
};
46+
WriteObject(setting);
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)