Skip to content

Commit 04d10f7

Browse files
committed
Merge pull request #4 from TianoMS/MoveRG
Fix Websites and Sql case failures.
2 parents 52ce5cf + 4ea664f commit 04d10f7

File tree

6 files changed

+76
-33
lines changed

6 files changed

+76
-33
lines changed

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/ResourceGroups/RemoveAzureResourceGroupCmdlet.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public override void ExecuteCmdlet()
5959
ProjectResources.RemoveResourceGroupMessage,
6060
Name,
6161
() => ResourceManagerSdkClient.DeleteResourceGroup(Name));
62+
63+
WriteObject(true);
6264
}
6365
}
6466
}

src/ResourceManager/Resources/Commands.Resources.Test/Commands.Resources.Test.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@
8282
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5945.28173-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
8383
</Reference>
8484
<Reference Include="Microsoft.Azure.Test.HttpRecorder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
85-
<SpecificVersion>False</SpecificVersion>
8685
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.6.0-preview\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
87-
<Private>True</Private>
8886
</Reference>
8987
<Reference Include="Microsoft.Data.Edm">
9088
<SpecificVersion>False</SpecificVersion>
@@ -143,9 +141,7 @@
143141
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.1.1\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
144142
</Reference>
145143
<Reference Include="Microsoft.WindowsAzure.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
146-
<SpecificVersion>False</SpecificVersion>
147144
<HintPath>..\..\..\packages\WindowsAzure.Storage.6.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
148-
<Private>True</Private>
149145
</Reference>
150146
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
151147
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/Resources/Commands.Resources/Models.ResourceGroups/ResourceClient.ResourceManager.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,31 +68,31 @@ public virtual List<PSResource> FilterPSResources(BasePSResourceParameters param
6868
throw new ArgumentException(ProjectResources.ResourceDoesntExists);
6969
}
7070

71-
//resources.Add(getResult.Resource.ToPSResource(this, false));
71+
resources.Add(getResult.Resource.ToPSResource(this, false));
7272
}
7373
else
7474
{
75-
//PSTagValuePair tagValuePair = new PSTagValuePair();
76-
//if (parameters.Tag != null && parameters.Tag.Length == 1 && parameters.Tag[0] != null)
77-
//{
78-
// tagValuePair = TagsConversionHelper.Create(parameters.Tag[0]);
79-
// if (tagValuePair == null)
80-
// {
81-
// throw new ArgumentException(ProjectResources.InvalidTagFormat);
82-
// }
83-
//}
84-
//ResourceListResult listResult = ResourceManagementClient.Resources.List(new ResourceListParameters
85-
//{
86-
// ResourceGroupName = parameters.ResourceGroupName,
87-
// ResourceType = parameters.ResourceType,
88-
// TagName = tagValuePair.Name,
89-
// TagValue = tagValuePair.Value
90-
//});
75+
PSTagValuePair tagValuePair = new PSTagValuePair();
76+
if (parameters.Tag != null && parameters.Tag.Length == 1 && parameters.Tag[0] != null)
77+
{
78+
tagValuePair = TagsConversionHelper.Create(parameters.Tag[0]);
79+
if (tagValuePair == null)
80+
{
81+
throw new ArgumentException(ProjectResources.InvalidTagFormat);
82+
}
83+
}
84+
ResourceListResult listResult = ResourceManagementClient.Resources.List(new ResourceListParameters
85+
{
86+
ResourceGroupName = parameters.ResourceGroupName,
87+
ResourceType = parameters.ResourceType,
88+
TagName = tagValuePair.Name,
89+
TagValue = tagValuePair.Value
90+
});
9191

92-
//if (listResult.Resources != null)
93-
//{
94-
// resources.AddRange(listResult.Resources.Select(r => r.ToPSResource(this, false)));
95-
//}
92+
if (listResult.Resources != null)
93+
{
94+
resources.AddRange(listResult.Resources.Select(r => r.ToPSResource(this, false)));
95+
}
9696
}
9797
return resources;
9898
}

src/ResourceManager/Resources/Commands.Resources/Models.ResourceGroups/ResourceClient.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
using Microsoft.Azure.Commands.Common.Authentication.Models;
1818
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
1919
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Utilities;
20+
using Microsoft.Azure.Commands.Resources.Models.Authorization;
2021
using Microsoft.Azure.Management.Authorization;
22+
using Microsoft.Azure.Management.Authorization.Models;
2123
using Microsoft.Azure.Management.Resources;
2224
using Microsoft.Azure.Management.Resources.Models;
2325
using Microsoft.WindowsAzure.Commands.Utilities.Common;
@@ -133,6 +135,20 @@ public DeploymentExtended ProvisionDeploymentStatus(string resourceGroup, string
133135
ProvisioningState.Failed);
134136
}
135137

138+
internal List<PSPermission> GetResourcePermissions(ResourceIdentifier identity)
139+
{
140+
PermissionGetResult permissionsResult = AuthorizationManagementClient.Permissions.ListForResource(
141+
identity.ResourceGroupName,
142+
identity.ToResourceIdentity());
143+
144+
if (permissionsResult != null)
145+
{
146+
return permissionsResult.Permissions.Select(p => p.ToPSPermission()).ToList();
147+
}
148+
149+
return null;
150+
}
151+
136152
private void WriteDeploymentProgress(string resourceGroup, string deploymentName, Deployment deployment)
137153
{
138154
const string normalStatusFormat = "Resource {0} '{1}' provisioning status is {2}";

src/ResourceManager/Resources/Commands.Resources/Models.ResourceGroups/ResourcesExtensions.cs

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Commands.Resources.Models.Authorization;
16-
using Microsoft.Azure.Commands.Tags.Model;
17-
using Microsoft.Azure.Gallery;
18-
using Microsoft.Azure.Management.Resources.Models;
19-
using Microsoft.WindowsAzure.Commands.Utilities.Common;
20-
using Newtonsoft.Json;
2115
using System;
2216
using System.Collections;
2317
using System.Collections.Generic;
2418
using System.Linq;
2519
using System.Reflection;
2620
using System.Text;
21+
using Microsoft.Azure.Commands.Common.Authentication;
22+
using Microsoft.Azure.Commands.Resources.Models.Authorization;
23+
using Microsoft.Azure.Commands.Tags.Model;
24+
using Microsoft.Azure.Gallery;
25+
using Microsoft.Azure.Management.Authorization.Models;
26+
using Microsoft.Azure.Management.Resources.Models;
27+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
28+
using Newtonsoft.Json;
2729

2830
namespace Microsoft.Azure.Commands.Resources.Models
2931
{
@@ -40,6 +42,33 @@ public static PSGalleryItem ToPSGalleryItem(this GalleryItem gallery)
4042
return psGalleryItem;
4143
}
4244

45+
public static PSResource ToPSResource(this GenericResourceExtended resource, ResourcesClient client, bool minimal)
46+
{
47+
ResourceIdentifier identifier = new ResourceIdentifier(resource.Id);
48+
return new PSResource
49+
{
50+
Name = identifier.ResourceName,
51+
Location = resource.Location,
52+
ResourceType = identifier.ResourceType,
53+
ResourceGroupName = identifier.ResourceGroupName,
54+
ParentResource = identifier.ParentResource,
55+
Properties = JsonUtilities.DeserializeJson(resource.Properties),
56+
PropertiesText = resource.Properties,
57+
Tags = TagsConversionHelper.CreateTagHashtable(resource.Tags),
58+
Permissions = minimal ? null : client.GetResourcePermissions(identifier),
59+
ResourceId = identifier.ToString()
60+
};
61+
}
62+
63+
public static PSPermission ToPSPermission(this Permission permission)
64+
{
65+
return new PSPermission()
66+
{
67+
Actions = new List<string>(permission.Actions),
68+
NotActions = new List<string>(permission.NotActions)
69+
};
70+
}
71+
4372
private static string ConstructTemplateLinkView(TemplateLink templateLink)
4473
{
4574
if (templateLink == null)

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/Common.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ Creates the test environment needed to perform the Sql data masking tests
107107
function Create-DataMaskingTestEnvironment ($testSuffix)
108108
{
109109
$params = Get-SqlDataMaskingTestEnvironmentParameters $testSuffix
110-
New-AzureRmResourceGroup -Name $params.rgname -Location "Australia East" -Force
111-
New-AzureRmResourceGroupDeployment -ResourceGroupName $params.rgname -TemplateFile ".\Templates\sql-ddm-test-env-setup.json" -serverName $params.serverName -databaseName $params.databaseName -EnvLocation "Australia East" -administratorLogin $params.userName -Force
110+
$rg = New-AzureRmResourceGroup -Name $params.rgname -Location "Australia East" -Force
111+
$rgdeployment = New-AzureRmResourceGroupDeployment -ResourceGroupName $params.rgname -TemplateFile ".\Templates\sql-ddm-test-env-setup.json" -serverName $params.serverName -databaseName $params.databaseName -EnvLocation "Australia East" -administratorLogin $params.userName -Force
112112
$fullServerName = $params.serverName + ".database.windows.net"
113113

114114
$uid = $params.userName

0 commit comments

Comments
 (0)