Skip to content

Commit f16d5cd

Browse files
committed
Get/Set AzureRmRecoveryServices changes
1 parent e586593 commit f16d5cd

File tree

12 files changed

+129
-20
lines changed

12 files changed

+129
-20
lines changed

src/Common/Commands.Common/Commands.Common.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<RestorePackages>true</RestorePackages>
1616
<CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>
1717
<NuGetPackageImportStamp>06e19c11</NuGetPackageImportStamp>
18+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\ResourceManager\RecoveryServices\</SolutionDir>
1819
</PropertyGroup>
1920
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2021
<DebugSymbols>true</DebugSymbols>
@@ -189,4 +190,11 @@
189190
</ItemGroup>
190191
<ItemGroup />
191192
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
193+
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
194+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
195+
<PropertyGroup>
196+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
197+
</PropertyGroup>
198+
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
199+
</Target>
192200
</Project>

src/ResourceManager/Common/Commands.ResourceManager.Common/Commands.ResourceManager.Common.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,11 @@
295295
</ProjectReference>
296296
</ItemGroup>
297297
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
298+
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
299+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
300+
<PropertyGroup>
301+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
302+
</PropertyGroup>
303+
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
304+
</Target>
298305
</Project>

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Commands.ScenarioTests.ResourceManager.Common.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,11 @@
171171
</ProjectReference>
172172
</ItemGroup>
173173
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
174+
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
175+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
176+
<PropertyGroup>
177+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
178+
</PropertyGroup>
179+
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
180+
</Target>
174181
</Project>

src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,11 @@
204204
</ItemGroup>
205205
<ItemGroup />
206206
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
207+
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
208+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
209+
<PropertyGroup>
210+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
211+
</PropertyGroup>
212+
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
213+
</Target>
207214
</Project>

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Test/Commands.RecoveryServices.Test.csproj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
4949
</Reference>
5050
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
51-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.1.0.2-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
52-
<Private>True</Private>
51+
<SpecificVersion>False</SpecificVersion>
52+
<HintPath>..\..\..\..\..\..\SafeHaven-1604\dll\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
5353
</Reference>
5454
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
5555
<SpecificVersion>False</SpecificVersion>
@@ -166,4 +166,11 @@
166166
</ItemGroup>
167167
<ItemGroup />
168168
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
169+
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
170+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
171+
<PropertyGroup>
172+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
173+
</PropertyGroup>
174+
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
175+
</Target>
169176
</Project>

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Test/ScenarioTests/RecoveryServicesTestsBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static T GetServiceClient<T>() where T : class
8484
if (testEnvironment.UsesCustomUri())
8585
{
8686
client = new RecoveryServicesManagementClient(
87-
"Microsoft.RecoveryServicesBVTD2",
87+
"Microsoft.RecoveryServicesBVTD",
8888
testEnvironment.Credentials as SubscriptionCloudCredentials,
8989
testEnvironment.BaseUri);
9090
}

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Commands.RecoveryServices.csproj

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
5353
</Reference>
5454
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
55-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.1.0.2-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
56-
<Private>True</Private>
55+
<SpecificVersion>False</SpecificVersion>
56+
<HintPath>..\..\..\..\..\..\SafeHaven-1604\dll\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
5757
</Reference>
5858
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.18.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
5959
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
@@ -129,6 +129,7 @@
129129
</Compile>
130130
<Compile Include="Utilities\CertUtils.cs" />
131131
<Compile Include="Utilities\Utilities.cs" />
132+
<Compile Include="Vault\SetAzureRmRecoveryServicesVaults.cs" />
132133
<Compile Include="Vault\GetAzureRmRecoveryServicesVaults.cs" />
133134
<Compile Include="Vault\GetAzureRmRecoveryServicesVaultSettingsFile.cs" />
134135
<Compile Include="Vault\NewAzureRmRecoveryServicesVault.cs" />
@@ -165,4 +166,11 @@
165166
</Content>
166167
</ItemGroup>
167168
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
169+
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
170+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
171+
<PropertyGroup>
172+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
173+
</PropertyGroup>
174+
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
175+
</Target>
168176
</Project>

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Common/PSRecoveryServicesVaultClient.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,29 @@ public ResourceGroupListResponse GetResouceGroups()
6363
{
6464
return this.GetRecoveryServicesClient.ResourceGroup.List();
6565
}
66+
67+
/// <summary>
68+
/// Method to Update Azure Recovery Services Vault Backup Properties
69+
/// </summary>
70+
/// <param name="resouceGroupName">Name of the resouce group</param>
71+
/// <param name="vaultName">Name of the vault</param>
72+
/// <param name="vaultStorageUpdateRequest">Backup Properties Update</param>
73+
/// <returns>Azure Operation response object.</returns>
74+
public AzureOperationResponse UpdateVaultStorageType(string resouceGroupName, string vaultName, UpdateVaultStorageTypeRequest vaultStorageUpdateRequest)
75+
{
76+
return this.recoveryServicesClient.Vaults.UpdateStorageType(resouceGroupName, vaultName,
77+
vaultStorageUpdateRequest, this.GetRequestHeaders());
78+
}
79+
80+
/// <summary>
81+
/// Method to Get Azure Recovery Services Vault Backup Properties
82+
/// </summary>
83+
/// <param name="resouceGroupName">Name of the resouce group</param>
84+
/// <param name="vaultName">Name of the vault</param>
85+
/// <returns>Azure Resource Storage response object.</returns>
86+
public GetResourceStorageConfigResponse GetVaultStorageType(string resouceGroupName, string vaultName)
87+
{
88+
return this.recoveryServicesClient.Vaults.GetResourceStorageConfig(resouceGroupName, vaultName, this.GetRequestHeaders());
89+
}
6690
}
6791
}

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Models/PSContracts.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,9 @@ public class AcsNamespace
520520
/// <param name="acsDetails">authenticating service Details name</param>
521521
public AcsNamespace(UploadCertificateResponse acsDetails)
522522
{
523-
this.HostName = acsDetails.Properties.GlobalAcsHostName;
524-
this.Namespace = acsDetails.Properties.GlobalAcsNamespace;
525-
this.ResourceProviderRealm = acsDetails.Properties.GlobalAcsRPRealm;
523+
this.HostName = (acsDetails.Properties as ACSCertificateProperties).GlobalAcsHostName;
524+
this.Namespace = (acsDetails.Properties as ACSCertificateProperties).GlobalAcsNamespace;
525+
this.ResourceProviderRealm = (acsDetails.Properties as ACSCertificateProperties).GlobalAcsRPRealm;
526526
}
527527

528528
/// <summary>

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Models/PSObjects.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,22 @@ public ARSVault(VaultCreateResponse vault)
135135
public class ASRVaultProperties
136136
{
137137
#region Properties
138-
138+
139139
/// <summary>
140140
/// Gets or sets Provisioning State.
141141
/// </summary>
142142
public string ProvisioningState { get; set; }
143143

144+
/// <summary>
145+
/// Gets or sets BackupStorageRedundancy type.
146+
/// </summary>
147+
public string BackupStorageRedundancy { get; set; }
148+
149+
/// <summary>
150+
/// Gets or sets BackupStorageDeduplication type.
151+
/// </summary>
152+
public string BackupStorageDeduplication { get; set; }
153+
144154
#endregion
145155
}
146156

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Vault/GetAzureRmRecoveryServicesVaults.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,15 @@ private void GetVaultsUnderAllResourceGroups()
9494
/// <param name="vaults">List of Vaults</param>
9595
private void WriteVaults(IList<Vault> vaults)
9696
{
97-
if (string.IsNullOrEmpty(this.Name))
97+
foreach (Vault vault in vaults)
9898
{
99-
this.WriteObject(vaults.Select(v => new ARSVault(v)), true);
100-
}
101-
else
102-
{
103-
foreach (Vault vault in vaults)
99+
if (0 == string.Compare(this.Name, vault.Name, true))
104100
{
105-
if (0 == string.Compare(this.Name, vault.Name, true))
106-
{
107-
this.WriteObject(new ARSVault(vault));
108-
}
101+
ARSVault rsVault = new ARSVault(vault);
102+
GetResourceStorageConfigResponse getStorageResponse = RecoveryServicesClient.GetVaultStorageType(this.ResourceGroupName, vault.Name);
103+
rsVault.Properties.BackupStorageRedundancy = getStorageResponse.Properties.StorageType;
104+
rsVault.Properties.BackupStorageDeduplication = getStorageResponse.Properties.DedupState;
105+
this.WriteObject(new ARSVault(vault));
109106
}
110107
}
111108
}

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Vault/NewAzureRMRecoveryServicesVault.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ public class NewAzureRmRecoveryServicesVault : RecoveryServicesCmdletBase
4747
[ValidateNotNullOrEmpty]
4848
public string Location { get; set; }
4949

50+
/// <summary>
51+
/// Gets or sets BackupStorageRedundancy type
52+
/// </summary>
53+
[Parameter(Mandatory = false)]
54+
public string BackupStorageRedundancy { get; set; }
55+
56+
/// <summary>
57+
/// Gets or sets BackupStorageDeduplication type
58+
/// </summary>
59+
[Parameter(Mandatory = false)]
60+
public string BackupStorageDeduplication { get; set; }
61+
62+
5063
#endregion
5164

5265
/// <summary>
@@ -64,7 +77,28 @@ public override void ExecuteCmdlet()
6477

6578
VaultCreateResponse response = RecoveryServicesClient.CreateVault(this.ResourceGroupName, this.Name, vaultCreateArgs);
6679

67-
this.WriteObject(new ARSVault(response));
80+
if (!(string.IsNullOrEmpty(this.BackupStorageRedundancy) && string.IsNullOrEmpty(this.BackupStorageDeduplication)))
81+
{
82+
UpdateVaultStorageTypeRequest vaultStorageRequest = new UpdateVaultStorageTypeRequest();
83+
vaultStorageRequest.Properties = new StorageTypeProperties();
84+
vaultStorageRequest.Properties.StorageModelType = this.BackupStorageRedundancy;
85+
vaultStorageRequest.Properties.DedupState = this.BackupStorageDeduplication;
86+
AzureOperationResponse storageResponse = RecoveryServicesClient.UpdateVaultStorageType(this.ResourceGroupName, this.Name, vaultStorageRequest);
87+
}
88+
89+
VaultListResponse vaultList = RecoveryServicesClient.GetVaultsInResouceGroup(this.ResourceGroupName);
90+
foreach (Vault vault in vaultList.Vaults)
91+
{
92+
if (vault.Name.Equals(this.Name, StringComparison.InvariantCultureIgnoreCase))
93+
{
94+
ARSVault rsVault = new ARSVault(vault);
95+
GetResourceStorageConfigResponse getStorageResponse = RecoveryServicesClient.GetVaultStorageType(this.ResourceGroupName, this.Name);
96+
rsVault.Properties.BackupStorageRedundancy = getStorageResponse.Properties.StorageType;
97+
rsVault.Properties.BackupStorageDeduplication = getStorageResponse.Properties.DedupState;
98+
this.WriteObject(rsVault);
99+
break;
100+
}
101+
}
68102
}
69103
catch (Exception exception)
70104
{

0 commit comments

Comments
 (0)