Skip to content

Dev #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Dec 30, 2015
Merged

Dev #283

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8047d55
Fixing protectable items list call to honour Next Link
Apselvan Dec 14, 2015
aa3ddf8
It contains:
avneeshraiusit Dec 15, 2015
b2a5c9c
To leverage service filtering
sriramvu Dec 16, 2015
074c73f
Fix for exception error object serialization
avneeshraiusit Dec 16, 2015
26e1d69
StartTime and EndTime to be shown as localtime and to convert to UTC …
sriramvu Dec 18, 2015
4aa8733
handling null checks for Start and End times of Jobs
sriramvu Dec 18, 2015
18769b4
Removing All filter while fetching protectable items and handling nul…
avneeshraiusit Dec 21, 2015
41c1cfb
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
avneeshraiusit Dec 21, 2015
f3a1451
Adding support for purge and showing protectionstatedescription for VMs
avneeshraiusit Dec 22, 2015
2edcc7d
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
avneeshraiusit Dec 28, 2015
d04b35d
Fix Endpoint Suffix when using New-AzureStorageContext specifying -En…
Dec 28, 2015
ee307c9
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
avneeshraiusit Dec 29, 2015
0229838
Updating session records for siterecovery project
avneeshraiusit Dec 29, 2015
2c603ab
Updating session records for RecoveryServices Project
avneeshraiusit Dec 29, 2015
614b4f4
Updating siterecovery csproj files
avneeshraiusit Dec 29, 2015
3745478
Merge pull request #1545 from hovsepm/dev
markcowl Dec 30, 2015
b1b2a42
Taking PR comments
avneeshraiusit Dec 30, 2015
d6db63e
Merge pull request #280 from Azure/dev
huangpf Dec 30, 2015
f411197
Merge pull request #1553 from AsrArmOneSdk/dev151125release
Dec 30, 2015
10e6ff4
Merge pull request #281 from Azure/dev
huangpf Dec 30, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class NewAzureStorageContext : AzureDataCmdlet
/// </summary>
private const string AnonymousEnvironmentParameterSet = "AnonymousAccountEnvironment";

private const string StorageAccountNameHelpMessage = "Azure Storage Acccount Name";
private const string StorageAccountNameHelpMessage = "Azure Storage Account Name";
[Parameter(Position = 0, HelpMessage = StorageAccountNameHelpMessage,
Mandatory = true, ParameterSetName = AccountNameKeyParameterSet)]
[Parameter(Position = 0, HelpMessage = StorageAccountNameHelpMessage,
Expand Down Expand Up @@ -283,7 +283,7 @@ internal CloudStorageAccount GetAnonymousStorageAccountFromAzureEnvironment(stri
/// <summary>
/// Get storage account and use specific end point
/// </summary>
/// <param name="credential">Storage credentail</param>
/// <param name="credential">Storage credential</param>
/// <param name="storageAccountName">Storage account name, it's used for build end point</param>
/// <param name="useHttps"></param>
/// <param name="endPoint"></param>
Expand Down Expand Up @@ -350,6 +350,19 @@ internal CloudStorageAccount GetStorageAccountWithAzureEnvironment(StorageCreden
}
}

if(null == azureEnvironment)
{
try
{
var profileClient = new ProfileClient(new AzureSMProfile());
azureEnvironment = profileClient.GetEnvironmentOrDefault(azureEnvironmentName);
}
catch(ArgumentException e)
{
throw new ArgumentException(e.Message + " " + string.Format(CultureInfo.CurrentCulture, Resources.ValidEnvironmentName, EnvironmentName.AzureCloud, EnvironmentName.AzureChinaCloud));
}
}

}

if (null != azureEnvironment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.1.0.1-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.1.0.2-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Test.Framework, Version=1.0.5774.40163, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.Azure.Test.Framework, Version=1.0.5799.28345, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5774.40163-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5799.28345-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Test.HttpRecorder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5774.40163-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5799.28345-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Recovery Services Vault CRUD Tests
function Test-RecoveryServicesVaultCRUDTests
{
# Create vault
$vaultCreationResponse = New-AzureRmRecoveryServicesVault -Name rsv1 -ResouceGroupName testsitegroup -Location westus
$vaultCreationResponse = New-AzureRmRecoveryServicesVault -Name rsv1 -ResourceGroupName S91-1 -Location westus
Assert-NotNull($vaultCreationResponse.Name)
Assert-NotNull($vaultCreationResponse.ID)
Assert-NotNull($vaultCreationResponse.Type)
Expand All @@ -38,16 +38,13 @@ function Test-RecoveryServicesVaultCRUDTests
}

# Get the created vault
$vaultToBeRemoved = Get-AzureRmRecoveryServicesVault -ResourceGroupName testsitegroup -Name rsv1
$vaultToBeRemoved = Get-AzureRmRecoveryServicesVault -ResourceGroupName S91-1 -Name rsv1
Assert-NotNull($vaultToBeRemoved.Name)
Assert-NotNull($vaultToBeRemoved.ID)
Assert-NotNull($vaultToBeRemoved.Type)

# Download Vault settings file
Get-AzureRmRecoveryServicesVaultSettingsFile -Vault $vaultToBeRemoved

# Remove Vault
Remove-AzureRmRecoveryServicesVault -Vault $vaultToBeRemoved
$vaults = Get-AzureRmRecoveryServicesVault -ResourceGroupName testsitegroup -Name rsv1
$vaults = Get-AzureRmRecoveryServicesVault -ResourceGroupName S91-1 -Name rsv1
Assert-True { $vaults.Count -eq 0 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ public static T GetServiceClient<T>() where T : class
if (testEnvironment.UsesCustomUri())
{
client = new RecoveryServicesManagementClient(
"Microsoft.RecoveryServices",
"Microsoft.RecoveryServicesBVTD2",
testEnvironment.Credentials as SubscriptionCloudCredentials,
testEnvironment.BaseUri);
}
else
{
client = new RecoveryServicesManagementClient(
"Microsoft.RecoveryServices",
"Microsoft.RecoveryServicesBVTD2",
testEnvironment.Credentials as SubscriptionCloudCredentials);
}
return GetServiceClient<T>(factory, client);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Authentication" version="1.5.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.RecoveryServices" version="1.0.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.RecoveryServices" version="1.0.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.5774.40163-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5774.40163-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.5799.28345-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5799.28345-prerelease" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.1.0.1-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.1.0.2-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.18.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public partial class PSRecoveryServicesClient
/// <returns>vault list response object.</returns>
public VaultListResponse GetVaultsInResouceGroup(string resouceGroupName)
{
return this.GetRecoveryServicesClient.Vaults.Get(resouceGroupName, this.GetRequestHeaders());
return this.GetRecoveryServicesClient.Vaults.List(resouceGroupName, this.GetRequestHeaders());
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
using Hyak.Common;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Microsoft.Azure.Commands.ResourceManager.Common;
using Newtonsoft.Json;
using System.Text;

namespace Microsoft.Azure.Commands.RecoveryServices
{
Expand Down Expand Up @@ -68,36 +70,46 @@ public void HandleException(Exception ex)
CloudException cloudException = ex as CloudException;
if (cloudException != null)
{
Error error = null;
ARMError error = null;
try
{
using (Stream stream = new MemoryStream())
if (cloudException.Message != null)
{
if (cloudException.Message != null)
{
byte[] data = System.Text.Encoding.UTF8.GetBytes(cloudException.Message);
stream.Write(data, 0, data.Length);
stream.Position = 0;
string originalMessage = cloudException.Error.OriginalMessage;
error = JsonConvert.DeserializeObject<ARMError>(originalMessage);

StringBuilder exceptionMessage = new StringBuilder();
exceptionMessage.Append(Properties.Resources.CloudExceptionDetails);

var deserializer = new DataContractSerializer(typeof(ErrorInException));
error = (Error)deserializer.ReadObject(stream);
if (error.Error.Details != null)
{
foreach (ARMExceptionDetails detail in error.Error.Details)
{
if (!string.IsNullOrEmpty(detail.ErrorCode))
exceptionMessage.AppendLine("ErrorCode: " + detail.ErrorCode);
if (!string.IsNullOrEmpty(detail.Message))
exceptionMessage.AppendLine("Message: " + detail.Message);

throw new InvalidOperationException(
string.Format(
Properties.Resources.CloudExceptionDetails,
error.Message,
error.PossibleCauses,
error.RecommendedAction,
error.ClientRequestId));
exceptionMessage.AppendLine();
}
}
else
{
throw new Exception(
string.Format(
Properties.Resources.InvalidCloudExceptionErrorMessage,
clientRequestIdMsg + ex.Message),
ex);
if (!string.IsNullOrEmpty(error.Error.ErrorCode))
exceptionMessage.AppendLine("ErrorCode: " + error.Error.ErrorCode);
if (!string.IsNullOrEmpty(error.Error.Message))
exceptionMessage.AppendLine("Message: " + error.Error.Message);
}

throw new InvalidOperationException(exceptionMessage.ToString());
}
else
{
throw new Exception(
string.Format(
Properties.Resources.InvalidCloudExceptionErrorMessage,
clientRequestIdMsg + ex.Message),
ex);
}
}
catch (XmlException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Text;
using Microsoft.Azure.Commands.RecoveryServices;
using Microsoft.Azure.Management.RecoveryServices.Models;
using Newtonsoft.Json;

namespace Microsoft.Azure.Commands.RecoveryServices
{
Expand Down Expand Up @@ -86,15 +87,107 @@ public enum RpErrorCode
}

/// <summary>
/// Error contract returned when some exception occurs in ASR REST API.
/// ARM specified Error
/// </summary>
[SuppressMessage(
public class ARMError
{
/// <summary>
/// Gets ARM formatted exception.
/// </summary>
[JsonProperty(PropertyName = "error")]
public ARMException Error { get; private set; }
}

/// <summary>
/// ARM exception class.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.StyleCop.CSharp.MaintainabilityRules",
"SA1402:FileMayOnlyContainASingleClass",
Justification = "Keeping all contracts together.")]
[DataContract]
public class ErrorInException : Error
Justification = "Keeping all related classes together.")]
public class ARMException
{
/// <summary>
/// Gets HTTP status code for the error.
/// </summary>
[JsonProperty(PropertyName = "code")]
public string ErrorCode { get; private set; }

/// <summary>
/// Gets exception message.
/// </summary>
[JsonProperty(PropertyName = "message")]
public string Message { get; private set; }

/// <summary>
/// Gets exception target.
/// </summary>
[JsonProperty(PropertyName = "target",
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore)]
public string Target { get; private set; }

/// <summary>
/// Gets service based error details.
/// </summary>
[JsonProperty(PropertyName = "details")]
public List<ARMExceptionDetails> Details { get; private set; }
}

/// <summary>
/// Service based exception details.
/// </summary>
public class ARMExceptionDetails
{
/// <summary>
/// Gets service error code.
/// </summary>
[JsonProperty(PropertyName = "code")]
public string ErrorCode { get; private set; }

/// <summary>
/// Gets error message.
/// </summary>
[JsonProperty(PropertyName = "message")]
public string Message { get; private set; }

/// <summary>
/// Gets possible cause for error.
/// </summary>
[JsonProperty(PropertyName = "possibleCauses",
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore)]
public string PossibleCauses { get; private set; }

/// <summary>
/// Gets recommended action for the error.
/// </summary>
[JsonProperty(PropertyName = "recommendedAction",
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore)]
public string RecommendedAction { get; private set; }

/// <summary>
/// Gets the client request Id for the session.
/// </summary>
[JsonProperty(PropertyName = "clientRequestId",
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore)]
public string ClientRequestId { get; private set; }

/// <summary>
/// Gets the activity Id for the session.
/// </summary>
[JsonProperty(PropertyName = "activityId")]
public string ActivityId { get; private set; }

/// <summary>
/// Gets exception target.
/// </summary>
[JsonProperty(PropertyName = "target",
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore)]
public string Target { get; private set; }
}

/// <summary>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@
</resheader>
<data name="CloudExceptionDetails" xml:space="preserve">
<value>Operation Failed.
Message: {0}
Possible Causes: {1}
Recommended Action: {2}
ClientRequestId: {3}</value>
</value>
</data>
<data name="CloudServiceNameNullOrEmpty" xml:space="preserve">
<value>Cloud Service name mentioned is either null or empty</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public class NewAzureRmRecoveryServicesVault : RecoveryServicesCmdletBase
public string Name { get; set; }

/// <summary>
/// Gets or sets the resouce group name
/// Gets or sets the resource group name
/// </summary>
[Parameter(Mandatory = true)]
[ValidateNotNullOrEmpty]
public string ResouceGroupName { get; set; }
public string ResourceGroupName { get; set; }

/// <summary>
/// Gets or sets the location of the vault
Expand All @@ -62,7 +62,7 @@ public override void ExecuteCmdlet()
vaultCreateArgs.Sku = new VaultSku();
vaultCreateArgs.Sku.Name = "standard";

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

this.WriteObject(new ARSVault(response));
}
Expand Down
Loading