diff --git a/src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs b/src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs
index d8641135ca63..d94cb1973b4b 100644
--- a/src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs
+++ b/src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs
@@ -12,9 +12,9 @@
// limitations under the License.
// ----------------------------------------------------------------------------------
+using Commands.Common.Authentication.Properties;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using System;
-using Commands.Common.Authentication.Properties;
namespace Microsoft.Azure.Commands.Common.Authentication
{
diff --git a/src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs b/src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs
index edfdab5317ae..92727df1fa05 100644
--- a/src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs
+++ b/src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs
@@ -12,14 +12,11 @@
// limitations under the License.
// ----------------------------------------------------------------------------------
+using Commands.Common.Authentication.Properties;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Rest;
using System;
-using System.Collections.Generic;
-using System.Security;
-using System.Security.Cryptography.X509Certificates;
-using Commands.Common.Authentication.Properties;
namespace Microsoft.Azure.Commands.Common.Authentication
{
diff --git a/src/CLU/Commands.Common.Authentication/Authentication/UserTokenProvider.cs b/src/CLU/Commands.Common.Authentication/Authentication/UserTokenProvider.cs
index 3d8b94b02cf6..c410c5678ed5 100644
--- a/src/CLU/Commands.Common.Authentication/Authentication/UserTokenProvider.cs
+++ b/src/CLU/Commands.Common.Authentication/Authentication/UserTokenProvider.cs
@@ -17,9 +17,9 @@
using Microsoft.Rest;
using System;
using System.Runtime.InteropServices;
-using Commands.Common.Authentication.Properties;
using Microsoft.Rest.Azure.Authentication;
using System.Management.Automation;
+using Commands.Common.Authentication.Properties;
namespace Microsoft.Azure.Commands.Common.Authentication
{
diff --git a/src/CLU/Commands.Common.Authentication/AuthenticationFactory.cs b/src/CLU/Commands.Common.Authentication/AuthenticationFactory.cs
index 4d05653310bd..82582ce93143 100644
--- a/src/CLU/Commands.Common.Authentication/AuthenticationFactory.cs
+++ b/src/CLU/Commands.Common.Authentication/AuthenticationFactory.cs
@@ -1,4 +1,4 @@
-// ----------------------------------------------------------------------------------
+// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,11 +16,10 @@
using System;
using System.Linq;
using System.Management.Automation;
-using System.Security;
-using Commands.Common.Authentication.Properties;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Rest;
using Microsoft.Rest.Azure.Authentication;
+using Commands.Common.Authentication.Properties;
namespace Microsoft.Azure.Commands.Common.Authentication.Factories
{
diff --git a/src/CLU/Commands.Common.Authentication/ClientFactory.cs b/src/CLU/Commands.Common.Authentication/ClientFactory.cs
index 5d2b105534c3..3ef47e696424 100644
--- a/src/CLU/Commands.Common.Authentication/ClientFactory.cs
+++ b/src/CLU/Commands.Common.Authentication/ClientFactory.cs
@@ -12,18 +12,17 @@
// limitations under the License.
// ----------------------------------------------------------------------------------
+using Commands.Common.Authentication.Properties;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Rest;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
-using System.Linq;
using System.Management.Automation;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Reflection;
-using Commands.Common.Authentication.Properties;
namespace Microsoft.Azure.Commands.Common.Authentication.Factories
{
diff --git a/src/CLU/Commands.Common.Authentication/JsonUtilities.cs b/src/CLU/Commands.Common.Authentication/JsonUtilities.cs
index 8804102bb551..590de89d7bd5 100644
--- a/src/CLU/Commands.Common.Authentication/JsonUtilities.cs
+++ b/src/CLU/Commands.Common.Authentication/JsonUtilities.cs
@@ -12,12 +12,12 @@
// limitations under the License.
// ----------------------------------------------------------------------------------
+using Commands.Common.Authentication.Properties;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
-using Commands.Common.Authentication.Properties;
namespace Microsoft.Azure.Commands.Common.Authentication
{
diff --git a/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs b/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs
index 0f92cd1759b5..6ada2999ef8b 100644
--- a/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs
+++ b/src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs
@@ -12,9 +12,9 @@
// limitations under the License.
// ----------------------------------------------------------------------------------
+using Commands.Common.Authentication.Properties;
using System;
using System.Collections.Generic;
-using Commands.Common.Authentication.Properties;
namespace Microsoft.Azure.Commands.Common.Authentication.Models
{
@@ -372,7 +372,7 @@ public static class AzureEnvironmentConstants
public const string USGovernmentSqlDatabaseDnsSuffix = ".database.usgovcloudapi.net";
- public const string AzureActiveDirectoryEndpoint = "https://login.windows.net/";
+ public const string AzureActiveDirectoryEndpoint = "https://login.microsoftonline.com/";
public const string ChinaActiveDirectoryEndpoint = "https://login.chinacloudapi.cn/";
diff --git a/src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs b/src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs
index 45ad834fc49b..6545dc95a074 100644
--- a/src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs
+++ b/src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs
@@ -12,12 +12,12 @@
// limitations under the License.
// ----------------------------------------------------------------------------------
+using Commands.Common.Authentication.Properties;
using Microsoft.Rest;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
-using Commands.Common.Authentication.Properties;
namespace Microsoft.Azure.Commands.Common.Authentication.Models
{
diff --git a/src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs b/src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs
index af11eab542a5..26bc7c5c23e8 100644
--- a/src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs
+++ b/src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs
@@ -12,11 +12,11 @@
// limitations under the License.
// ----------------------------------------------------------------------------------
+using Commands.Common.Authentication.Properties;
using System;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Text;
-using Commands.Common.Authentication.Properties;
namespace Microsoft.Azure.Commands.Common.Authentication.Models
{
diff --git a/src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs b/src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs
index 6ac14542c061..d9a39bacf125 100644
--- a/src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs
+++ b/src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs
@@ -140,15 +140,6 @@ internal static string AuthenticatingForSingleTenant {
}
}
- ///
- /// Looks up a localized string similar to Windows Azure Powershell.
- ///
- internal static string AzureDirectoryName {
- get {
- return ResourceManager.GetString("AzureDirectoryName", resourceCulture);
- }
- }
-
///
/// Looks up a localized string similar to No certificate was found in the certificate store with thumbprint {0}.
///
diff --git a/src/CLU/Commands.Common.Authentication/Properties/Resources.resx b/src/CLU/Commands.Common.Authentication/Properties/Resources.resx
index 6d8140059cc5..1e1662b54e32 100644
--- a/src/CLU/Commands.Common.Authentication/Properties/Resources.resx
+++ b/src/CLU/Commands.Common.Authentication/Properties/Resources.resx
@@ -120,9 +120,6 @@
Account needs to be specified
-
- Windows Azure Powershell
-
No certificate was found in the certificate store with thumbprint {0}
diff --git a/src/CLU/Commands.Common.Authentication/Validate.cs b/src/CLU/Commands.Common.Authentication/Validate.cs
index e25efbaeb580..497e02f4473d 100644
--- a/src/CLU/Commands.Common.Authentication/Validate.cs
+++ b/src/CLU/Commands.Common.Authentication/Validate.cs
@@ -12,10 +12,10 @@
// limitations under the License.
// ----------------------------------------------------------------------------------
+using Commands.Common.Authentication.Properties;
using System;
using System.IO;
using System.Linq;
-using Commands.Common.Authentication.Properties;
namespace Microsoft.Azure.Commands.Common.Authentication
{
diff --git a/src/CLU/Commands.Common/AzurePSCmdlet.cs b/src/CLU/Commands.Common/AzurePSCmdlet.cs
index 48fca661c3bf..a0d1b1ad30cb 100644
--- a/src/CLU/Commands.Common/AzurePSCmdlet.cs
+++ b/src/CLU/Commands.Common/AzurePSCmdlet.cs
@@ -436,17 +436,11 @@ protected virtual void WriteExceptionError(Exception ex)
WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.CloseError, null));
}
- protected PSObject ConstructPSObject(string typeName, params object[] args)
+ protected PSObject ConstructPSObject(params object[] args)
{
- return PowerShellUtilities.ConstructPSObject(typeName, args);
+ return PowerShellUtilities.ConstructPSObject(args);
}
-
- protected void SafeWriteOutputPSObject(string typeName, params object[] args)
- {
- PSObject customObject = this.ConstructPSObject(typeName, args);
- WriteObject(customObject);
- }
-
+
private void FlushDebugMessages(bool record = false)
{
if (record)
diff --git a/src/CLU/Commands.Common/Models/PSAzureContext.cs b/src/CLU/Commands.Common/Models/PSAzureContext.cs
index 263b16740c66..f84aeb5878d0 100644
--- a/src/CLU/Commands.Common/Models/PSAzureContext.cs
+++ b/src/CLU/Commands.Common/Models/PSAzureContext.cs
@@ -86,5 +86,14 @@ public static implicit operator AzureContext(PSAzureContext context)
public PSAzureTenant Tenant { get; set; }
public byte[] TokenCache { get; set; }
+
+ public override string ToString()
+ {
+ var account = Account != null ? Account.Id : string.Empty;
+ var subscription = Subscription != null ? Subscription.SubscriptionId : string.Empty;
+ var tenant = Tenant != null ? Tenant.TenantId : string.Empty;
+ var environment = Environment != null ? Environment.Name : EnvironmentName.AzureCloud;
+ return $"{{Account: {account}, Subscription: {subscription}, Tenant: {tenant}, Environment: {environment}}}";
+ }
}
}
diff --git a/src/CLU/Commands.Common/Models/PSAzureProfile.cs b/src/CLU/Commands.Common/Models/PSAzureProfile.cs
index f689c4b88c91..285dd052dfda 100644
--- a/src/CLU/Commands.Common/Models/PSAzureProfile.cs
+++ b/src/CLU/Commands.Common/Models/PSAzureProfile.cs
@@ -64,6 +64,11 @@ public IDictionary Environments
get { return _env; }
}
+ public string EnvironmentNames
+ {
+ get { return _env == null? null : $"{string.Join(", ", _env.Keys.ToArray())}"; }
+ }
+
///
/// The current credentials and metadata for connecting with the current Azure cloud instance.
///
diff --git a/src/CLU/Commands.Common/PowerShellUtilities.cs b/src/CLU/Commands.Common/PowerShellUtilities.cs
index 70577363ca6d..b5e98952b3cc 100644
--- a/src/CLU/Commands.Common/PowerShellUtilities.cs
+++ b/src/CLU/Commands.Common/PowerShellUtilities.cs
@@ -50,17 +50,12 @@ private static void ChangeForTargetEnvironment(Func, IEnumer
}
}
- public static PSObject ConstructPSObject(string typeName, params object[] args)
+ public static PSObject ConstructPSObject(params object[] args)
{
Debug.Assert(args.Length % 2 == 0, "The parameter args length must be even number");
PSObject outputObject = new PSObject();
-
- if (!string.IsNullOrEmpty(typeName))
- {
- outputObject.TypeNames.Add(typeName);
- }
-
+
for (int i = 0, j = 0; i < args.Length / 2; i++, j += 2)
{
outputObject.Properties.Add(new PSNoteProperty(args[j].ToString(), args[j + 1]));
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Locks/ResourceLock.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Locks/ResourceLock.cs
new file mode 100644
index 000000000000..ff93b218479d
--- /dev/null
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Locks/ResourceLock.cs
@@ -0,0 +1,32 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using Newtonsoft.Json;
+
+namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources
+{
+ public class ResourceLock : Resource
+ {
+ public ResourceLock(Resource r)
+ : base(r)
+ {
+ }
+
+ ///
+ /// Gets or sets the lock id for the resource.
+ ///
+ [JsonProperty(Required = Required.Default)]
+ public string LockId { get; set; }
+ }
+}
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Policy/ResourcePolicyAssignment.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Policy/ResourcePolicyAssignment.cs
new file mode 100644
index 000000000000..b5937d2fb57e
--- /dev/null
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Policy/ResourcePolicyAssignment.cs
@@ -0,0 +1,33 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources;
+using Newtonsoft.Json;
+
+namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Policy
+{
+ public class ResourcePolicyAssignment : Resource
+ {
+ public ResourcePolicyAssignment(Resource r)
+ : base(r)
+ {
+ }
+
+ ///
+ /// Gets or sets the policy assignment id for the resource.
+ ///
+ [JsonProperty(Required = Required.Default)]
+ public string PolicyAssignmentId { get; set; }
+ }
+}
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Policy/ResourcePolicyDefinition.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Policy/ResourcePolicyDefinition.cs
new file mode 100644
index 000000000000..6139213b4de9
--- /dev/null
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Policy/ResourcePolicyDefinition.cs
@@ -0,0 +1,33 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources;
+using Newtonsoft.Json;
+
+namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Policy
+{
+ public class ResourcePolicyDefinition : Resource
+ {
+ public ResourcePolicyDefinition(Resource r)
+ : base(r)
+ {
+ }
+
+ ///
+ /// Gets or sets the policy definition id for the resource.
+ ///
+ [JsonProperty(Required = Required.Default)]
+ public string PolicyDefinitionId { get; set; }
+ }
+}
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/Resource.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/Resource.cs
index 777e0354038a..c2f1df956fd6 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/Resource.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Entities/Resources/Resource.cs
@@ -23,6 +23,27 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources
///
public class Resource
{
+ public Resource()
+ {
+
+ }
+
+ public Resource(Resource r)
+ {
+ this.ChangedTime = r.ChangedTime;
+ this.CreatedTime = r.CreatedTime;
+ this.ETag = r.ETag;
+ this.Id = r.Id;
+ this.Kind = r.Kind;
+ this.Location = r.Location;
+ this.Name = r.Name;
+ this.Plan = r.Plan;
+ this.Properties = r.Properties;
+ this.Sku = r.Sku;
+ this.Tags = r.Tags;
+ this.Type = r.Type;
+ }
+
///
/// Gets or sets the properties.
///
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/JTokenExtensions.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/JTokenExtensions.cs
index 566a7626ea4e..0a9b410790fd 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/JTokenExtensions.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/JTokenExtensions.cs
@@ -48,7 +48,7 @@ internal static class JTokenExtensions
///
/// The
/// The type of the object.
- internal static PSObject ToPsObject(this JToken jtoken, string objectType = null)
+ internal static PSObject ToPsObject(this JToken jtoken)
{
if (jtoken == null)
{
@@ -63,12 +63,7 @@ internal static PSObject ToPsObject(this JToken jtoken, string objectType = null
var jobject = (JObject)jtoken;
var psObject = new PSObject();
-
- if (!string.IsNullOrWhiteSpace(objectType))
- {
- psObject.TypeNames.Add(objectType);
- }
-
+
foreach (var property in jobject.Properties())
{
psObject.Properties.Add(new PSNoteProperty(
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/PsObjectExtensions.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/PsObjectExtensions.cs
index 2d4fd867ff83..1b5f3ee6b217 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/PsObjectExtensions.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/PsObjectExtensions.cs
@@ -86,9 +86,7 @@ private static JToken ToJToken(object value)
}
else
{
- var properties = (valueAsPsObject.TypeNames.Any(typeName => typeName.EqualsInsensitively(Constants.MicrosoftAzureResource)))
- ? valueAsPsObject.Properties.Where(property => !PsObjectExtensions.PropertiesToRemove.ContainsKey(property.Name))
- : valueAsPsObject.Properties.AsEnumerable();
+ var properties = valueAsPsObject.Properties.AsEnumerable();
foreach (var member in properties)
{
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/ResourceExtensions.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/ResourceExtensions.cs
index e27dd8767048..8cd4d869994e 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/ResourceExtensions.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Extensions/ResourceExtensions.cs
@@ -61,16 +61,10 @@ internal static PSObject ToPsObject(this Resource resource)
{ "Sku", resource.Sku == null ? null : resource.Sku.ToJToken().ToPsObject() },
};
- var resourceTypeName = resourceType == null && extensionResourceType == null
- ? null
- : (resourceType + extensionResourceType).Replace('/', '.');
-
var psObject =
PowerShellUtilities.ConstructPSObject(
- resourceTypeName,
objectDefinition.Where(kvp => kvp.Value != null).SelectManyArray(kvp => new[] { kvp.Key, kvp.Value }));
-
- psObject.TypeNames.Add(Constants.MicrosoftAzureResource);
+
return psObject;
}
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/GetAzureResourceGroupDeploymentOperationCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/GetAzureResourceGroupDeploymentOperationCmdlet.cs
index 143661d453f5..548aa7426584 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/GetAzureResourceGroupDeploymentOperationCmdlet.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/GetAzureResourceGroupDeploymentOperationCmdlet.cs
@@ -25,7 +25,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
///
/// Gets the deployment operation.
///
- [Cmdlet(VerbsCommon.Get, "AzureRmResourceGroupDeploymentOperation"), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.Get, "AzureRmResourceGroupDeploymentOperation"), OutputType(typeof(Resource))]
public class GetAzureResourceGroupDeploymentOperationCmdlet : ResourceManagerCmdletBase
{
///
@@ -81,7 +81,7 @@ private void RunCmdlet()
getFirstPage: () => this.GetResources(),
getNextPage: nextLink => this.GetNextLink(nextLink),
cancellationToken: this.CancellationToken,
- action: resources => this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(resource => resource.ToPsObject()), enumerateCollection: true));
+ action: resources => this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(resource => resource.ToResource()), enumerateCollection: true));
}
///
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/GetAzureResourceLockCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/GetAzureResourceLockCmdlet.cs
index 00cca469d5be..36e570f7d830 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/GetAzureResourceLockCmdlet.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/GetAzureResourceLockCmdlet.cs
@@ -19,11 +19,11 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions;
using Newtonsoft.Json.Linq;
-
+ using Entities.Resources;
///
/// Gets the resource lock.
///
- [Cmdlet(VerbsCommon.Get, "AzureRmResourceLock"), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.Get, "AzureRmResourceLock"), OutputType(typeof(ResourceLock))]
public class GetAzureResourceLockCmdlet : ResourceLockManagementCmdletBase
{
///
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/NewAzureResourceLockCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/NewAzureResourceLockCmdlet.cs
index d6f6b6feab59..ed63088cbdce 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/NewAzureResourceLockCmdlet.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/NewAzureResourceLockCmdlet.cs
@@ -18,11 +18,12 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Locks;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions;
using Newtonsoft.Json.Linq;
-
+ using Entities.Resources;
///
/// The new azure resource lock cmdlet.
///
- [Cmdlet(VerbsCommon.New, "AzureRmResourceLock", SupportsShouldProcess = true, DefaultParameterSetName = ResourceLockManagementCmdletBase.SubscriptionResourceLevelLock), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.New, "AzureRmResourceLock", SupportsShouldProcess = true, DefaultParameterSetName = ResourceLockManagementCmdletBase.SubscriptionResourceLevelLock),
+ OutputType(typeof(ResourceLock))]
public class NewAzureResourceLockCmdlet : ResourceLockManagementCmdletBase
{
///
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/RemoveAzureResourceLockCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/RemoveAzureResourceLockCmdlet.cs
index e46cb174da66..1a76f691a855 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/RemoveAzureResourceLockCmdlet.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/RemoveAzureResourceLockCmdlet.cs
@@ -20,7 +20,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
///
/// The remove azure resource lock cmdlet.
///
- [Cmdlet(VerbsCommon.Remove, "AzureRmResourceLock", SupportsShouldProcess = true), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.Remove, "AzureRmResourceLock", SupportsShouldProcess = true), OutputType(typeof(bool))]
public class RemoveAzureResourceLockCmdlet : ResourceLockManagementCmdletBase
{
///
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs
index e6c87263fe7e..b7ddbefab94d 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs
@@ -77,7 +77,6 @@ public abstract class ResourceLockManagementCmdletBase : ResourceManagerCmdletBa
[Parameter(ParameterSetName = ResourceLockManagementCmdletBase.SubscriptionResourceLevelLock, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource name. e.g. to specify a database MyServer/MyDatabase.")]
[Parameter(ParameterSetName = ResourceLockManagementCmdletBase.TenantResourceLevelLock, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The resource name. e.g. to specify a database MyServer/MyDatabase.")]
[ValidateNotNullOrEmpty]
- [Alias("name", "n")]
public string ResourceName { get; set; }
///
@@ -151,16 +150,17 @@ protected string GetResourceId(string lockName)
/// Converts the resource object to output that can be piped to the lock cmdlets.
///
/// The lock resource object.
- protected PSObject[] GetOutputObjects(params JToken[] resources)
+ protected ResourceLock[] GetOutputObjects(params JToken[] resources)
{
return resources
.CoalesceEnumerable()
.Where(resource => resource != null)
.SelectArray(resource =>
{
- var psobject = resource.ToResource().ToPsObject();
- psobject.Properties.Add(new PSNoteProperty("LockId", psobject.Properties["ResourceId"].Value));
- return psobject;
+ var rc = resource.ToResource();
+ var resourceLock = new ResourceLock(rc);
+ resourceLock.LockId = rc.Id;
+ return resourceLock;
});
}
}
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/SetAzureResourceLockCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/SetAzureResourceLockCmdlet.cs
index edf3b3789b42..7404305f59f0 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/SetAzureResourceLockCmdlet.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Lock/SetAzureResourceLockCmdlet.cs
@@ -14,12 +14,15 @@
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
{
+ using Entities.Resources;
+ using Newtonsoft.Json.Linq;
using System.Management.Automation;
///
/// The set resource lock cmdlet.
///
- [Cmdlet(VerbsCommon.Set, "AzureRmResourceLock", SupportsShouldProcess = true, DefaultParameterSetName = ResourceLockManagementCmdletBase.SubscriptionResourceLevelLock), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.Set, "AzureRmResourceLock", SupportsShouldProcess = true, DefaultParameterSetName = ResourceLockManagementCmdletBase.SubscriptionResourceLevelLock),
+ OutputType(typeof(ResourceLock))]
public class SetAzureResourceLockCmdlet : NewAzureResourceLockCmdlet
{
///
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyAssignment.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyAssignment.cs
index 4ec1add1e685..130a0947db06 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyAssignment.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyAssignment.cs
@@ -19,11 +19,11 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions;
using Newtonsoft.Json.Linq;
-
+ using Entities.Policy;
///
/// Gets the policy assignment.
///
- [Cmdlet(VerbsCommon.Get, "AzureRmPolicyAssignment", DefaultParameterSetName = GetAzurePolicyAssignmentCmdlet.ParameterlessSet), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.Get, "AzureRmPolicyAssignment", DefaultParameterSetName = GetAzurePolicyAssignmentCmdlet.ParameterlessSet), OutputType(typeof(ResourcePolicyAssignment))]
public class GetAzurePolicyAssignmentCmdlet : PolicyAssignmentCmdletBase
{
///
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyDefinition.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyDefinition.cs
index 02eb9fc6ad31..18b767997cbf 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyDefinition.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/GetAzurePolicyDefinition.cs
@@ -19,11 +19,11 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions;
using Newtonsoft.Json.Linq;
-
+ using Entities.Policy;
///
/// Gets the policy definition.
///
- [Cmdlet(VerbsCommon.Get, "AzureRmPolicyDefinition", DefaultParameterSetName = GetAzurePolicyDefinitionCmdlet.ParameterlessSet), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.Get, "AzureRmPolicyDefinition", DefaultParameterSetName = GetAzurePolicyDefinitionCmdlet.ParameterlessSet), OutputType(typeof(ResourcePolicyDefinition))]
public class GetAzurePolicyDefinitionCmdlet : PolicyDefinitionCmdletBase
{
///
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyAssignment.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyAssignment.cs
index 4cb71ebced19..cea7a2970081 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyAssignment.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyAssignment.cs
@@ -23,7 +23,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
///
/// Creates a policy assignment.
///
- [Cmdlet(VerbsCommon.New, "AzureRmPolicyAssignment"), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.New, "AzureRmPolicyAssignment"), OutputType(typeof(ResourcePolicyAssignment))]
public class NewAzurePolicyAssignmentCmdlet : PolicyAssignmentCmdletBase
{
///
@@ -51,8 +51,8 @@ public class NewAzurePolicyAssignmentCmdlet : PolicyAssignmentCmdletBase
///
/// Gets or sets the policy assignment policy definition parameter.
///
- [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The pollicy definition object.")]
- public PSObject PolicyDefinition { get; set; }
+ [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The policy definition id object.")]
+ public string PolicyDefinitionId { get; set; }
///
/// Executes the cmdlet.
@@ -60,10 +60,6 @@ public class NewAzurePolicyAssignmentCmdlet : PolicyAssignmentCmdletBase
protected override void OnProcessRecord()
{
base.OnProcessRecord();
- if(this.PolicyDefinition.Properties["policyDefinitionId"] == null)
- {
- throw new PSInvalidOperationException("The supplied PolicyDefinition object is invalid.");
- }
string resourceId = GetResourceId();
var apiVersion = this.DetermineApiVersion(resourceId: resourceId).Result;
@@ -111,7 +107,7 @@ private JToken GetResource()
Properties = new PolicyAssignmentProperties
{
DisplayName = this.DisplayName ?? null,
- PolicyDefinitionId = this.PolicyDefinition.Properties["policyDefinitionId"].Value.ToString(),
+ PolicyDefinitionId = PolicyDefinitionId,
Scope = this.Scope
}
};
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyDefinition.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyDefinition.cs
index a02f8a67895c..ae2cecfe1317 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyDefinition.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/NewAzurePolicyDefinition.cs
@@ -25,7 +25,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
///
/// Creates the policy definition.
///
- [Cmdlet(VerbsCommon.New, "AzureRmPolicyDefinition"), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.New, "AzureRmPolicyDefinition"), OutputType(typeof(ResourcePolicyDefinition))]
public class NewAzurePolicyDefinitionCmdlet : PolicyDefinitionCmdletBase
{
///
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyAssignmentCmdletBase.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyAssignmentCmdletBase.cs
index ba523ad3b9d4..94dbebe03861 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyAssignmentCmdletBase.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyAssignmentCmdletBase.cs
@@ -21,7 +21,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions;
using Newtonsoft.Json.Linq;
-
+ using Entities.Policy;
///
/// Base class for policy assignment cmdlets.
///
@@ -42,16 +42,17 @@ protected Task> GetNextLink(string next
/// Converts the resource object to policy definition object.
///
/// The policy definition resource object.
- protected PSObject[] GetOutputObjects(params JToken[] resources)
+ protected ResourcePolicyAssignment[] GetOutputObjects(params JToken[] resources)
{
return resources
.CoalesceEnumerable()
.Where(resource => resource != null)
.SelectArray(resource =>
{
- var psobject = resource.ToResource().ToPsObject();
- psobject.Properties.Add(new PSNoteProperty("PolicyAssignmentId", psobject.Properties["ResourceId"].Value));
- return psobject;
+ var rc = resource.ToResource();
+ var res = new ResourcePolicyAssignment(rc);
+ res.PolicyAssignmentId = rc.Id;
+ return res;
});
}
}
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyDefinitionCmdletBase.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyDefinitionCmdletBase.cs
index 799c7751ee73..dcab1b660fa2 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyDefinitionCmdletBase.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/PolicyDefinitionCmdletBase.cs
@@ -21,7 +21,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions;
using Newtonsoft.Json.Linq;
-
+ using Entities.Policy;
///
/// Base class for policy definition cmdlets.
///
@@ -42,16 +42,17 @@ protected Task> GetNextLink(string next
/// Converts the resource object to policy definition object.
///
/// The policy definition resource object.
- protected PSObject[] GetOutputObjects(params JToken[] resources)
+ protected ResourcePolicyDefinition[] GetOutputObjects(params JToken[] resources)
{
return resources
.CoalesceEnumerable()
.Where(resource => resource != null)
.SelectArray(resource =>
{
- var psobject = resource.ToResource().ToPsObject();
- psobject.Properties.Add(new PSNoteProperty("PolicyDefinitionId", psobject.Properties["ResourceId"].Value));
- return psobject;
+ var rc = resource.ToResource();
+ var res = new ResourcePolicyDefinition(rc);
+ res.PolicyDefinitionId = rc.Id;
+ return res;
});
}
}
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyAssignment.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyAssignment.cs
index 23d62a553140..2d18d8de2303 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyAssignment.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyAssignment.cs
@@ -24,7 +24,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
///
/// Sets the policy assignment.
///
- [Cmdlet(VerbsCommon.Set, "AzureRmPolicyAssignment", DefaultParameterSetName = SetAzurePolicyAssignmentCmdlet.PolicyAssignmentNameParameterSet), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.Set, "AzureRmPolicyAssignment", DefaultParameterSetName = SetAzurePolicyAssignmentCmdlet.PolicyAssignmentNameParameterSet), OutputType(typeof(ResourcePolicyAssignment))]
public class SetAzurePolicyAssignmentCmdlet : PolicyAssignmentCmdletBase
{
///
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyDefinition.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyDefinition.cs
index 81ff53ea8c8c..333a6ef74aaf 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyDefinition.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Policy/SetAzurePolicyDefinition.cs
@@ -26,7 +26,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
///
/// Sets the policy definition.
///
- [Cmdlet(VerbsCommon.Set, "AzureRmPolicyDefinition", DefaultParameterSetName = SetAzurePolicyDefinitionCmdlet.PolicyDefinitionNameParameterSet), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.Set, "AzureRmPolicyDefinition", DefaultParameterSetName = SetAzurePolicyDefinitionCmdlet.PolicyDefinitionNameParameterSet), OutputType(typeof(ResourcePolicyDefinition))]
public class SetAzurePolicyDefinitionCmdlet : PolicyDefinitionCmdletBase
{
///
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/FindAzureResourceCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/FindAzureResourceCmdlet.cs
index 544c25315940..4a60f6497cd3 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/FindAzureResourceCmdlet.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/FindAzureResourceCmdlet.cs
@@ -29,7 +29,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
///
/// Cmdlet to get existing resources from ARM cache.
///
- [Cmdlet(VerbsCommon.Find, "AzureRmResource", DefaultParameterSetName = FindAzureResourceCmdlet.ListResourcesParameterSet), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.Find, "AzureRmResource", DefaultParameterSetName = FindAzureResourceCmdlet.ListResourcesParameterSet), OutputType(typeof(Resource))]
public sealed class FindAzureResourceCmdlet : ResourceManagerCmdletBase
{
///
@@ -191,14 +191,14 @@ private void RunCmdlet()
items = this.GetPopulatedResource(batch).Result;
}
- var powerShellObjects = items.SelectArray(genericResource => genericResource.ToPsObject());
+ var powerShellObjects = items.SelectArray(genericResource => genericResource);
this.WriteObject(sendToPipeline: powerShellObjects, enumerateCollection: true);
}
}
else
{
- this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(res => res.ToPsObject()), enumerateCollection: true);
+ this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(res => res.ToResource()), enumerateCollection: true);
}
});
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs
index 38de888a634f..46e23dd1721b 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/GetAzureResourceCmdlet.cs
@@ -29,11 +29,11 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
///
/// Cmdlet to get existing resources.
///
- [Cmdlet(VerbsCommon.Get, "AzureRmResource", DefaultParameterSetName = GetAzureResourceCmdlet.ParameterlessSet), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.Get, "AzureRmResource", DefaultParameterSetName = GetAzureResourceCmdlet.ParameterlessSet), OutputType(typeof(Resource))]
public sealed class GetAzureResourceCmdlet : ResourceManagerCmdletBase
{
///
- /// Contains the errors that encountered while satifying the request.
+ /// Contains the errors that encountered while satisfying the request.
///
private readonly ConcurrentBag errors = new ConcurrentBag();
@@ -228,14 +228,14 @@ private void RunCmdlet()
items = this.GetPopulatedResource(batch).Result;
}
- var powerShellObjects = items.SelectArray(genericResource => genericResource.ToPsObject());
+ var powerShellObjects = items.SelectArray(genericResource => genericResource);
this.WriteObject(sendToPipeline: powerShellObjects, enumerateCollection: true);
}
}
else
{
- this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(res => res.ToPsObject()), enumerateCollection: true);
+ this.WriteObject(sendToPipeline: resources.CoalesceEnumerable().SelectArray(res => res.ToResource()), enumerateCollection: true);
}
});
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/NewAzureResourceCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/NewAzureResourceCmdlet.cs
index 22c469cc8731..670dce29e0e4 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/NewAzureResourceCmdlet.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/NewAzureResourceCmdlet.cs
@@ -26,7 +26,11 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
///
/// A cmdlet that creates a new azure resource.
///
- [Cmdlet(VerbsCommon.New, "AzureRmResource", SupportsShouldProcess = true, DefaultParameterSetName = ResourceManipulationCmdletBase.ResourceIdParameterSet), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.New,
+ "AzureRmResource",
+ SupportsShouldProcess = true,
+ DefaultParameterSetName = ResourceManipulationCmdletBase.ResourceIdParameterSet),
+ OutputType(typeof(Resource))]
public sealed class NewAzureResourceCmdlet : ResourceManipulationCmdletBase
{
///
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/SetAzureResourceCmdlet.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/SetAzureResourceCmdlet.cs
index 4db23b50d874..7edcd7c7d87d 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/SetAzureResourceCmdlet.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/Resource/SetAzureResourceCmdlet.cs
@@ -27,7 +27,8 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
///
/// A cmdlet that creates a new azure resource.
///
- [Cmdlet(VerbsCommon.Set, "AzureRmResource", SupportsShouldProcess = true, DefaultParameterSetName = ResourceManipulationCmdletBase.ResourceIdParameterSet), OutputType(typeof(PSObject))]
+ [Cmdlet(VerbsCommon.Set, "AzureRmResource", SupportsShouldProcess = true, DefaultParameterSetName = ResourceManipulationCmdletBase.ResourceIdParameterSet),
+ OutputType(typeof(Resource))]
public sealed class SetAzureResourceCmdlet : ResourceManipulationCmdletBase
{
///
diff --git a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/ResourceManagerCmdletBase.cs b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/ResourceManagerCmdletBase.cs
index d8ecf9a2937f..56e282f03e24 100644
--- a/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/ResourceManagerCmdletBase.cs
+++ b/src/CLU/Commands.ResourceManager.Cmdlets/Implementation/ResourceManagerCmdletBase.cs
@@ -301,7 +301,7 @@ protected void TryConvertToResourceAndWriteObject(string resultString)
Resource resultResource;
if (resultString.TryConvertTo>(out resultResource))
{
- this.WriteObject(resultResource.ToPsObject());
+ this.WriteObject(resultResource);
}
else
{
diff --git a/src/CLU/Microsoft.Azure.Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml b/src/CLU/Microsoft.Azure.Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml
index 8146c70da1f8..e745d0fcee98 100644
--- a/src/CLU/Microsoft.Azure.Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml
+++ b/src/CLU/Microsoft.Azure.Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml
@@ -1,10 +1,10 @@
-
- Microsoft.Azure.Commands.Profile.Models.PSAzureProfile
+
+ Microsoft.Azure.Commands.Models.PSAzureProfile
- Microsoft.Azure.Commands.Profile.Models.PSAzureProfile
+ Microsoft.Azure.Commands.Models.PSAzureProfile
@@ -12,36 +12,41 @@
-
Context
-
+
+
+ EnvironmentNames
+
+
-
+ -->
- Microsoft.Azure.Commands.Profile.Models.PSAzureContext
+ Microsoft.Azure.Commands.Models.PSAzureContext
- Microsoft.Azure.Commands.Profile.Models.PSAzureContext
+ Microsoft.Azure.Commands.Models.PSAzureContext
+
Environment
+
Account
- Tenant
+ Tenant
- Subscription
+ Subscription
@@ -49,9 +54,9 @@
- Microsoft.Azure.Commands.Profile.Models.PSAzureSubscription
+ Microsoft.Azure.Commands.Models.PSAzureSubscription
- Microsoft.Azure.Commands.Profile.Models.PSAzureSubscription
+ Microsoft.Azure.Commands.Models.PSAzureSubscription
@@ -75,9 +80,9 @@
- Microsoft.Azure.Commands.Profile.Models.PSAzureTenant
+ Microsoft.Azure.Commands.Models.PSAzureTenant
- Microsoft.Azure.Commands.Profile.Models.PSAzureTenant
+ Microsoft.Azure.Commands.Models.PSAzureTenant
@@ -94,5 +99,58 @@
+
+ Microsoft.Azure.Commands.Models.PSAzureEnvironment
+
+ Microsoft.Azure.Commands.Models.PSAzureEnvironment
+
+
+
+
+
+
+ Name
+
+
+
+ ActiveDirectoryAuthority
+
+
+
+ ResourceManagerUrl
+
+
+
+ GraphUrl
+
+
+
+ GalleryUrl
+
+
+
+ AdTenant
+
+
+
+ ActiveDirectoryServiceEndpointResourceId
+
+
+
+ AzureKeyVaultServiceEndpointResourceId
+
+
+
+ AzureKeyVaultDnsSuffix
+
+
+
+ EnableAdfsAuthentication
+
+
+
+
+
+
diff --git a/src/CLU/Microsoft.Azure.Commands.Resources/Tags/GetAzureTagCommand.cs b/src/CLU/Microsoft.Azure.Commands.Resources/Tags/GetAzureTagCommand.cs
index 273bcbc34ee7..3f976d621cec 100644
--- a/src/CLU/Microsoft.Azure.Commands.Resources/Tags/GetAzureTagCommand.cs
+++ b/src/CLU/Microsoft.Azure.Commands.Resources/Tags/GetAzureTagCommand.cs
@@ -51,7 +51,6 @@ protected override void ProcessRecord()
{
List output = new List();
tags.ForEach(t => output.Add(base.ConstructPSObject(
- null,
"Name", t.Name,
"Count", t.Count)));
diff --git a/src/CLU/Microsoft.CLU.Run/project.json b/src/CLU/Microsoft.CLU.Run/project.json
index e505e09d2a3c..7816d770b9db 100644
--- a/src/CLU/Microsoft.CLU.Run/project.json
+++ b/src/CLU/Microsoft.CLU.Run/project.json
@@ -9,7 +9,6 @@
"Microsoft.NETCore": "5.0.1-beta-23516",
"Microsoft.NETCore.Runtime": "1.0.1-beta-23516",
"Microsoft.NETCore.Platforms": "1.0.1-beta-23516",
- "Microsoft.NETCore.ConsoleHost": "1.0.0-beta-23516",
"Microsoft.NETCore.Runtime.CoreCLR": "1.0.1-beta-23516",
"System.Console": "4.0.0-beta-23516",
"System.Diagnostics.Process": "4.1.0-beta-23516",
diff --git a/src/CLU/Microsoft.CLU/Helpers/FormatReader.cs b/src/CLU/Microsoft.CLU/Helpers/FormatReader.cs
index 6c7d59e99030..efe91f469753 100644
--- a/src/CLU/Microsoft.CLU/Helpers/FormatReader.cs
+++ b/src/CLU/Microsoft.CLU/Helpers/FormatReader.cs
@@ -136,13 +136,13 @@ private static void GetTableColumnItems(TableDescriptor table, XElement tableCon
}
}
- private static void GetListItems(ListDescriptor list, XElement tableControl)
+ private static void GetListItems(ListDescriptor list, XElement listControl)
{
- var tableHeaders = GetChildrenMatching(tableControl, "ListEntries").FirstOrDefault();
+ var listEntries = GetChildrenMatching(listControl, "ListEntries").FirstOrDefault();
- if (tableHeaders != null)
+ if (listEntries != null)
{
- foreach (var entry in GetChildrenMatching(tableHeaders, "ListEntry"))
+ foreach (var entry in GetChildrenMatching(listEntries, "ListEntry"))
{
foreach (var items in GetChildrenMatching(entry, "ListItems"))
{
@@ -152,6 +152,7 @@ private static void GetListItems(ListDescriptor list, XElement tableControl)
var label = GetChildrenMatching(item, "Label").FirstOrDefault();
var propertyName = GetChildrenMatching(item, "PropertyName").FirstOrDefault();
+ var property = GetChildrenMatching(item, "Property").FirstOrDefault();
if (label != null && !string.IsNullOrEmpty(label.Value))
{
@@ -160,6 +161,16 @@ private static void GetListItems(ListDescriptor list, XElement tableControl)
if (propertyName != null && !string.IsNullOrEmpty(propertyName.Value))
{
column.ItemName = propertyName.Value;
+ if (string.IsNullOrEmpty(column.Header))
+ {
+ column.Header = propertyName.Value;
+ }
+ }
+
+ if (property != null && !string.IsNullOrEmpty(property.Value) &&
+ string.IsNullOrEmpty(column.ItemName))
+ {
+ column.ItemName = property.Value;
}
if (!string.IsNullOrEmpty(column.ItemName) && !string.IsNullOrEmpty(column.Header))
diff --git a/src/CLU/clurun/project.json b/src/CLU/clurun/project.json
index 795e22f30df1..2794647e986e 100644
--- a/src/CLU/clurun/project.json
+++ b/src/CLU/clurun/project.json
@@ -7,7 +7,6 @@
"Microsoft.NETCore": "5.0.1-beta-23516",
"Microsoft.NETCore.Runtime": "1.0.1-beta-23516",
"Microsoft.NETCore.Platforms": "1.0.1-beta-23516",
- "Microsoft.NETCore.ConsoleHost": "1.0.0-beta-23516",
"Microsoft.NETCore.Runtime.CoreCLR": "1.0.1-beta-23516",
"System.Console": "4.0.0-beta-23516",
"System.Diagnostics.Process": "4.1.0-beta-23516",
diff --git a/tools/CLU/BuildAndInstallClu.bat b/tools/CLU/BuildAndInstallClu.bat
index 4d4ae2c99a16..59b09899b0ee 100644
--- a/tools/CLU/BuildAndInstallClu.bat
+++ b/tools/CLU/BuildAndInstallClu.bat
@@ -6,6 +6,17 @@ if ERRORLEVEL 1 (
echo Please install 'dotnet', say from 'https://azureclu.blob.core.windows.net/tools/dotnet-win-x64.latest.zip', unzip, then add its bin folder to the PATH
exit /B 1
)
+
+pushd
+cd %root%\src\CLU
+call dnu.cmd restore
+if ERRORLEVEL 1 (
+ echo "dnu.cmd restore" failed under folder of "%root%\src\CLU"
+ popd
+ exit /B 1
+)
+popd
+
@powershell -file %~dp0\BuildDrop.ps1
REM cook a msclu.cfg with a correct local repro path.
@@ -29,11 +40,20 @@ REM note, for known nuget bugs, skip --install by copying over cmdlet packages.
xcopy %root%\drop\clurun\win7-x64\pkgs %root%\drop\clurun\osx.10.10-x64\pkgs /S /Q /I /Y
copy /Y %root%\drop\clurun\win7-x64\azure.lx %root%\drop\clurun\osx.10.10-x64
copy /Y %root%\drop\clurun\win7-x64\msclu.cfg %root%\drop\clurun\osx.10.10-x64
+
+REM: copy over the pre-cooked azure.sh and ensure correct line endings
copy /Y %~dp0\azure.sh %root%\drop\clurun\osx.10.10-x64
+set azuresh=%root%\drop\clurun\osx.10.10-x64\azure.sh
+echo Get-ChildItem %azuresh% ^| ForEach-Object { > %temp%\fixLineEndings.ps1
+echo $contents = [IO.File]::ReadAllText($_) -replace "`r`n?", "`n" >> %temp%\fixLineEndings.ps1
+echo [IO.File]::WriteAllText($_, $contents) >> %temp%\fixLineEndings.ps1
+echo } >> %temp%\fixLineEndings.ps1
+@powershell -file %temp%\fixLineEndings.ps1
xcopy %root%\drop\clurun\win7-x64\pkgs %root%\drop\clurun\ubuntu.14.04-x64\pkgs /S /Q /I /Y
copy /Y %root%\drop\clurun\win7-x64\azure.lx %root%\drop\clurun\ubuntu.14.04-x64
copy /Y %root%\drop\clurun\win7-x64\msclu.cfg %root%\drop\clurun\ubuntu.14.04-x64
-copy /Y %~dp0\azure.sh %root%\drop\clurun\ubuntu.14.04-x64
+copy /Y %azuresh% %root%\drop\clurun\ubuntu.14.04-x64
-copy /Y %~dp0\azure %root%\drop\clurun\win7-x64
+REM, windows version also needs it for bash based testing
+copy /Y %azuresh% %root%\drop\clurun\win7-x64\azure
diff --git a/tools/CLU/BuildDrop.ps1 b/tools/CLU/BuildDrop.ps1
index 7e0dfc822340..325cc5450624 100644
--- a/tools/CLU/BuildDrop.ps1
+++ b/tools/CLU/BuildDrop.ps1
@@ -17,7 +17,15 @@ if (!($dropLocation))
if (!(Test-Path -Path $dropLocation -PathType Container))
{
mkdir "$dropLocation"
+}
+
+if (!(Test-Path -Path "$dropLocation\CommandRepo" -PathType Container))
+{
mkdir "$dropLocation\CommandRepo"
+}
+
+if (!(Test-Path -Path "$dropLocation\clurun" -PathType Container))
+{
mkdir "$dropLocation\clurun"
}
@@ -50,8 +58,8 @@ if (!($excludeCluRun))
if (!($runtime.StartsWith("win")))
{
- # Fix current x-plat dotnet publish by correctly renaming ConsoleHost to clurun
- Move-Item -Path "$cluRunOutput\coreconsole" -Destination "$cluRunOutput\clurun" -Force
+ # use released coreconsole file from https://github.com/dotnet/cli
+ Copy-Item -Path "$workspaceDirectory\tools\CLU\$runtime\coreconsole" -Destination "$cluRunOutput\clurun" -Force
# Remove all extra exes that end up in the output directory...
Get-ChildItem -Path "$cluRunOutput" -Filter "*.exe" | Remove-Item
diff --git a/tools/CLU/BuildPackage.ps1 b/tools/CLU/BuildPackage.ps1
index 6beefbc67529..d9a60cfcd634 100644
--- a/tools/CLU/BuildPackage.ps1
+++ b/tools/CLU/BuildPackage.ps1
@@ -2,16 +2,16 @@
if (!(Test-Path $cmdletsDir))
{
- throw "cmdletsDir: '$cmdletsDir' must be an existing directory containing cmdlet code"
+ throw "cmdletsDir: '$cmdletsDir' must be an existing directory containing cmdlet code"
}
if (!(Test-Path $outputDir))
{
- throw "outputDir: '$outputDir' must be an existing directory"
+ throw "outputDir: '$outputDir' must be an existing directory"
}
if ([string]::IsNullOrWhiteSpace($env:WORKSPACE) -or !(Test-Path $env:WORKSPACE))
{
- throw "env:WORKSPACE: '$env:WORKSPACE' must be an existing directory"
+ throw "env:WORKSPACE: '$env:WORKSPACE' must be an existing directory"
}
$packageSource = $packageSource.TrimEnd('\\')
@@ -34,19 +34,19 @@ $contentFileText = ""
$contentFiles | %{ $contentFileText += (" `r`n")}
if ($packageId -ne "Microsoft.CLU.Commands")
{
- $contentFileText += " `r`n"
+ $contentFileText += " `r`n"
}
if ($renameFileExists)
{
- $contentFileText += " `r`n"
+ $contentFileText += " `r`n"
}
$contentFileText += " `r`n"
$sourceFileText = ""
$refFiles | %{$sourceFileText += (" `r`n")}
$outputContent = $fileContent -replace "%PackageVersion%", $packageVersion
$outputContent = $outputContent -replace "%ReferenceFiles%", $refFileText
- $outputContent = $outputContent -replace "%SourceFiles%", $sourceFileText
- $outputContent = $outputContent -replace "%ContentFiles%", $contentFileText
+$outputContent = $outputContent -replace "%SourceFiles%", $sourceFileText
+$outputContent = $outputContent -replace "%ContentFiles%", $contentFileText
Set-Content -Value $outputContent -Path $nuspecOutput
Write-Host "Creating nuget package..."
diff --git a/tools/CLU/SetupEnv.bat b/tools/CLU/SetupEnv.bat
index 5170bdd598ba..af64b5c0ac04 100644
--- a/tools/CLU/SetupEnv.bat
+++ b/tools/CLU/SetupEnv.bat
@@ -1,20 +1,13 @@
echo off
setlocal
set root=%~dp0..\..
-echo Build all clu source projects
-"%ProgramFiles(x86)%\MSBuild\14.0\Bin\msbuild" %root%\build.proj /t:build >NUL
-
-if ERRORLEVEL 1 (
- echo Build source project failed. To repro, run: msbuild build.proj /t:build
- exit /B 1
-)
REM build cmdlets packages
set DebugCLU=
call %~dp0\BuildAndInstallClu.bat
set Path=%Path%;%root%\drop\clurun\win7-x64
REM run 'azure help' to verify all are wired up
-azure help
+azure.bat help
if ERRORLEVEL 1 (
echo Build and deploy clu package failed
exit /B 1
diff --git a/tools/CLU/azure b/tools/CLU/azure
deleted file mode 100644
index 9b47ed34a551..000000000000
--- a/tools/CLU/azure
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-BASEDIR=$(dirname $0)
-
-clurun.exe -s azure -r $BASEDIR/azure.lx $*
\ No newline at end of file
diff --git a/tools/CLU/osx.10.10-x64/coreconsole b/tools/CLU/osx.10.10-x64/coreconsole
new file mode 100644
index 000000000000..f9058ac8ec0e
Binary files /dev/null and b/tools/CLU/osx.10.10-x64/coreconsole differ
diff --git a/tools/CLU/ubuntu.14.04-x64/coreconsole b/tools/CLU/ubuntu.14.04-x64/coreconsole
new file mode 100644
index 000000000000..a502adaab0f9
Binary files /dev/null and b/tools/CLU/ubuntu.14.04-x64/coreconsole differ