Skip to content

Commit d72a48b

Browse files
author
Nicholas King
committed
Fix build, rewrite deleted code
1 parent 62de610 commit d72a48b

File tree

6 files changed

+136
-9
lines changed

6 files changed

+136
-9
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
using System;
3+
using Microsoft.Azure.Management.WebSites.Models;
4+
5+
namespace Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps
6+
{
7+
public class AzureWebAppBackup
8+
{
9+
public string ResourceGroupName { get; set; }
10+
public string Name { get; set; }
11+
public string Slot { get; set; }
12+
public string StorageAccountUrl { get; set; }
13+
public string BlobName { get; set; }
14+
public DatabaseBackupSetting[] Databases { get; set; }
15+
public int? BackupId { get; set; }
16+
public string BackupName { get; set; }
17+
public string BackupStatus { get; set; }
18+
public bool Scheduled { get; set; }
19+
public long? BackupSizeInBytes { get; set; }
20+
public long? WebsiteSizeInBytes { get; set; }
21+
public DateTime? Created { get; set; }
22+
public DateTime? LastRestored { get; set; }
23+
public DateTime? Finished { get; set; }
24+
public string Log { get; set; }
25+
public string CorrelationId { get; set; }
26+
}
27+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
using System;
3+
using Microsoft.Azure.Management.WebSites.Models;
4+
5+
namespace Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps
6+
{
7+
public class AzureWebAppBackupConfiguration
8+
{
9+
public string Name { get; set; }
10+
public string ResourceGroupName { get; set; }
11+
public string StorageAccountUrl { get; set; }
12+
public int? FrequencyInterval { get; set; }
13+
public string FrequencyUnit { get; set; }
14+
public int? RetentionPeriodInDays { get; set; }
15+
public DateTime? StartTime { get; set; }
16+
public DatabaseBackupSetting[] Databases { get; set; }
17+
public bool? KeepAtLeastOneBackup { get; set; }
18+
public bool? Enabled { get; set; }
19+
}
20+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
2+
using System;
3+
using System.Linq;
4+
using Microsoft.Azure.Management.WebSites.Models;
5+
6+
namespace Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps
7+
{
8+
internal class BackupRestoreUtils
9+
{
10+
public static FrequencyUnit StringToFrequencyUnit(string frequencyUnit)
11+
{
12+
FrequencyUnit freq;
13+
Enum.TryParse(frequencyUnit, true, out freq);
14+
return freq;
15+
}
16+
17+
public static AzureWebAppBackup BackupItemToAppBackup(BackupItem backup, string resourceGroupName, string name, string slot)
18+
{
19+
var dbs = backup.Databases == null ? null : backup.Databases.ToArray();
20+
string status = backup.Status == null ? null : backup.Status.ToString();
21+
return new AzureWebAppBackup
22+
{
23+
ResourceGroupName = resourceGroupName,
24+
Name = name,
25+
Slot = slot,
26+
StorageAccountUrl = backup.StorageAccountUrl,
27+
BlobName = backup.BlobName,
28+
Databases = dbs,
29+
BackupId = backup.BackupItemId,
30+
BackupName = backup.BackupItemName,
31+
BackupStatus = status,
32+
Scheduled = backup.Scheduled,
33+
BackupSizeInBytes = backup.SizeInBytes,
34+
WebsiteSizeInBytes = backup.WebsiteSizeInBytes,
35+
Created = backup.Created,
36+
LastRestored = backup.LastRestoreTimeStamp,
37+
Finished = backup.FinishedTimeStamp,
38+
Log = backup.Log,
39+
CorrelationId = backup.CorrelationId
40+
};
41+
}
42+
43+
public static AzureWebAppBackupConfiguration BackupRequestToAppBackupConfiguration(BackupRequest configuration, string resourceGroupName, string name, string slot)
44+
{
45+
if (configuration == null)
46+
{
47+
return new AzureWebAppBackupConfiguration();
48+
}
49+
BackupSchedule schedule = configuration.BackupSchedule;
50+
DatabaseBackupSetting[] databases = null;
51+
bool? enabled = configuration.Enabled;
52+
if (configuration.Databases != null)
53+
{
54+
databases = configuration.Databases.ToArray();
55+
}
56+
57+
int? frequencyInterval = null;
58+
string frequencyUnit = null;
59+
int? retentionPeriodInDays = null;
60+
DateTime? startTime = null;
61+
bool? keepAtLeastOneBackup = null;
62+
if (schedule != null)
63+
{
64+
frequencyInterval = schedule.FrequencyInterval;
65+
if (schedule.FrequencyUnit != null)
66+
{
67+
frequencyUnit = schedule.FrequencyUnit.ToString();
68+
}
69+
retentionPeriodInDays = schedule.RetentionPeriodInDays;
70+
startTime = schedule.StartTime;
71+
keepAtLeastOneBackup = schedule.KeepAtLeastOneBackup;
72+
}
73+
74+
return new AzureWebAppBackupConfiguration()
75+
{
76+
Name = name,
77+
ResourceGroupName = resourceGroupName,
78+
StorageAccountUrl = configuration.StorageAccountUrl,
79+
FrequencyInterval = frequencyInterval,
80+
FrequencyUnit = frequencyUnit,
81+
RetentionPeriodInDays = retentionPeriodInDays,
82+
StartTime = startTime,
83+
Databases = databases,
84+
KeepAtLeastOneBackup = keepAtLeastOneBackup,
85+
Enabled = enabled
86+
};
87+
}
88+
}
89+
}

src/ResourceManager/Websites/Commands.Websites/Cmdlets/BackupRestore/RestoreAzureWebAppBackup.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,5 @@ public override void ExecuteCmdlet()
6161
// to restore from a backup that is no longer stored in our Backups table.
6262
WebsitesClient.RestoreSite(ResourceGroupName, Name, Slot, "1", request);
6363
}
64-
6564
}
6665
}

src/ResourceManager/Websites/Commands.Websites/Commands.Websites.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,6 @@
228228
<Project>{3819d8a7-c62c-4c47-8ddd-0332d9ce1252}</Project>
229229
<Name>Commands.ResourceManager.Common</Name>
230230
</ProjectReference>
231-
<ProjectReference Include="..\..\Profile\Commands.Profile\Commands.Profile.csproj">
232-
<Project>{142d7b0b-388a-4ceb-a228-7f6d423c5c2e}</Project>
233-
<Name>Commands.Profile</Name>
234-
</ProjectReference>
235231
<ProjectReference Include="..\..\Resources\Commands.Resources\Commands.Resources.csproj">
236232
<Project>{e1f5201d-6067-430e-b303-4e367652991b}</Project>
237233
<Name>Commands.Resources</Name>

src/ResourceManager/Websites/WebSites.sln

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Common", "..\..\Co
2424
EndProject
2525
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Common.Authentication", "..\..\Common\Commands.Common.Authentication\Commands.Common.Authentication.csproj", "{D3804B64-C0D3-48F8-82EC-1F632F833C9E}"
2626
EndProject
27-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Management.Storage", "..\Storage\Commands.Management.Storage\Commands.Management.Storage.csproj", "{A50AB133-5C04-4A17-9054-F8343683EC23}"
28-
EndProject
29-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Storage", "..\..\Storage\Commands.Storage\Commands.Storage.csproj", "{08CF7DA7-0392-4A19-B79B-E1FF67CDB81A}"
30-
EndProject
3127
Global
3228
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3329
Debug|Any CPU = Debug|Any CPU

0 commit comments

Comments
 (0)