Skip to content

Commit b117e97

Browse files
committed
Merge pull request #275 from NaveenGoli/save-branch
Save branch
2 parents eed3d12 + 661128a commit b117e97

38 files changed

+3235
-2102
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.17.0-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6060
</Reference>
6161
<Reference Include="Microsoft.Azure.Management.WebSites">
62-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.WebSites.0.16.1-prerelease\lib\net40\Microsoft.Azure.Management.WebSites.dll</HintPath>
62+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.WebSites.0.16.4-prerelease\lib\net40\Microsoft.Azure.Management.WebSites.dll</HintPath>
6363
</Reference>
6464
<Reference Include="Microsoft.Azure.ResourceManager">
6565
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.14.1-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
@@ -110,7 +110,7 @@
110110
<ItemGroup>
111111
<Compile Include="NewAzureWebsitesCommandTests.cs" />
112112
<Compile Include="ScenarioTests\WebsitesController.cs" />
113-
<Compile Include="ScenarioTests\WebsitesTests.cs" />
113+
<Compile Include="ScenarioTests\WebAppTests.cs" />
114114
<Compile Include="WebsitesTestHelpers.cs" />
115115
<Compile Include="Properties\AssemblyInfo.cs" />
116116
</ItemGroup>
@@ -122,13 +122,13 @@
122122
<None Include="ScenarioTests\Common.ps1">
123123
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
124124
</None>
125-
<None Include="ScenarioTests\WebsitesTests.ps1">
125+
<None Include="ScenarioTests\WebAppTests.ps1">
126126
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
127127
</None>
128-
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebsitesTests\TestCreatesNewSimpleWebsite.json">
128+
<None Include="SessionRecords\Microsoft.Azure.Commands.WebApp.Test.ScenarioTests.WebAppTests\TestCreatesNewAppServicePlan.json">
129129
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
130130
</None>
131-
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebsitesTests\TestCreatesNewWebHostingPlan.json">
131+
<None Include="SessionRecords\Microsoft.Azure.Commands.WebApp.Test.ScenarioTests.WebAppTests\TestCreatesNewSimpleWebApp.json">
132132
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
133133
</None>
134134
</ItemGroup>

src/ResourceManager/Websites/Commands.Websites.Test/NewAzureWebsitesCommandTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@
1515
using System.Collections;
1616
using System.Collections.Generic;
1717
using System.Management.Automation;
18-
using Microsoft.Azure.Commands.Websites.Utilities;
18+
using Microsoft.Azure.Commands.WebApp.Utilities;
1919
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2020
using Microsoft.WindowsAzure.Commands.Common;
21-
using Microsoft.Azure.Commands.Websites.Cmdlets;
22-
using Microsoft.Azure.Commands.Websites;
23-
using Microsoft.Azure.Commands.Websites.Models;
21+
using Microsoft.Azure.Commands.WebApp.Cmdlets;
22+
using Microsoft.Azure.Commands.WebApp;
23+
using Microsoft.Azure.Commands.WebApp.Models;
2424
using Moq;
2525
using Xunit;
2626

2727

2828

2929
namespace Microsoft.Azure.Commands.Websites.Test
3030
{
31-
public class NewAzureWebsiteCommandTests
31+
public class NewAzureWebAppCommandTests
3232
{
33-
private NewAzureWebsiteCmdlet cmdlet;
33+
private NewAzureWebAppCmdlet cmdlet;
3434

3535
private Mock<WebsitesClient> websitesClientMock;
3636

@@ -53,11 +53,11 @@ public class NewAzureWebsiteCommandTests
5353

5454
private Hashtable[] tags;
5555

56-
public NewAzureWebsiteCommandTests()
56+
public NewAzureWebAppCommandTests()
5757
{
5858
websitesClientMock = new Mock<WebsitesClient>();
5959
commandRuntimeMock = new Mock<ICommandRuntime>();
60-
cmdlet = new NewAzureWebsiteCmdlet()
60+
cmdlet = new NewAzureWebAppCmdlet()
6161
{
6262
CommandRuntime = commandRuntimeMock.Object,
6363
WebsitesClient = websitesClientMock.Object

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebsitesTests.cs renamed to src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebAppTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@
1616
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1717
using Xunit;
1818

19-
namespace Microsoft.Azure.Commands.Websites.Test.ScenarioTests
19+
namespace Microsoft.Azure.Commands.WebApp.Test.ScenarioTests
2020
{
21-
public class WebsitesTests
21+
public class WebAppTests
2222
{
2323
[Fact]
2424
[Trait(Category.AcceptanceType, Category.CheckIn)]
25-
public void TestCreatesNewSimpleWebsite()
25+
public void TestCreatesNewSimpleWebApp()
2626
{
27-
WebsitesController.NewInstance.RunPsTest("Test-CreatesNewSimpleWebsite");
27+
WebsitesController.NewInstance.RunPsTest("Test-CreatesNewSimpleWebApp");
2828
}
2929

3030
[Fact]
3131
[Trait(Category.AcceptanceType, Category.CheckIn)]
32-
public void TestCreatesNewWebHostingPlan()
32+
public void TestCreatesNewAppServicePlan()
3333
{
34-
WebsitesController.NewInstance.RunPsTest("Test-CreatesNewWebHostingPlan");
34+
WebsitesController.NewInstance.RunPsTest("Test-CreatesNewAppServicePlan");
3535
}
3636
}
3737
}

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebsitesTests.ps1 renamed to src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebAppTests.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
.SYNOPSIS
1717
Tests creating a new website.
1818
#>
19-
function Test-CreatesNewSimpleWebsite
19+
function Test-CreatesNewSimpleWebApp
2020
{
2121
# Setup
2222
$rgname = Get-ResourceGroupName
@@ -29,11 +29,11 @@ function Test-CreatesNewSimpleWebsite
2929
{
3030
#Setup
3131
New-AzureResourceGroup -Name $rgname -Location $location
32-
New-AzureWebHostingPlan -ResourceGroupName $rgname -WebHostingPlanName $whpName -location $location
32+
New-AzureAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $location
3333

3434
# Test
35-
$actual = New-AzureWebsite -ResourceGroupName $rgname -Name $wname -Location $location -WebHostingPlan $whpName
36-
$result = Get-AzureWebsite -ResourceGroupName $rgname -Name $wname
35+
$actual = New-AzureWebApp -ResourceGroupName $rgname -Name $wname -Location $location -AppServicePlan $whpName
36+
$result = Get-AzureWebApp -ResourceGroupName $rgname -Name $wname
3737

3838
# Assert
3939
Assert-AreEqual $wname $result.Name
@@ -42,8 +42,8 @@ function Test-CreatesNewSimpleWebsite
4242
finally
4343
{
4444
# Cleanup
45-
Remove-AzureWebsite -ResourceGroupName $rgname -Name $wname -Force
46-
Remove-AzureWebHostingPlan -ResourceGroupName $rgname -WebHostingPlanName $whpName -Force
45+
Remove-AzureWebApp -ResourceGroupName $rgname -Name $wname -Force
46+
Remove-AzureAppServicePlan -ResourceGroupName $rgname -Name $whpName -Force
4747
Remove-AzureResourceGroup -Name $rgname -Force
4848
}
4949
}
@@ -52,7 +52,7 @@ function Test-CreatesNewSimpleWebsite
5252
.SYNOPSIS
5353
Tests creating a new Web Hosting Plan.
5454
#>
55-
function Test-CreatesNewWebHostingPlan
55+
function Test-CreatesNewAppServicePlan
5656
{
5757
# Setup
5858
$rgname = Get-ResourceGroupName
@@ -64,8 +64,8 @@ function Test-CreatesNewWebHostingPlan
6464
#Setup
6565
New-AzureResourceGroup -Name $rgname -Location $location
6666
# Test
67-
$actual = New-AzureWebHostingPlan -ResourceGroupName $rgname -WebHostingPlanName $whpName -location $location
68-
$result = Get-AzureWebHostingPlan -ResourceGroupName $rgname -WebHostingPlanName $whpName
67+
$actual = New-AzureAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $location
68+
$result = Get-AzureAppServicePlan -ResourceGroupName $rgname -Name $whpName
6969
# Assert
7070
Assert-AreEqual $whpName $result.WebHostingPlan.Name
7171
Assert-AreEqual 1 $result.WebHostingPlan.Properties.NumberOfWorkers
@@ -75,7 +75,7 @@ function Test-CreatesNewWebHostingPlan
7575
finally
7676
{
7777
# Cleanup
78-
Remove-AzureWebHostingPlan -ResourceGroupName $rgname -WebHostingPlanName $whpName -Force
78+
Remove-AzureAppServicePlan -ResourceGroupName $rgname -Name $whpName -Force
7979
Remove-AzureResourceGroup -Name $rgname -Force
8080
}
8181
}

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebsitesController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
using Microsoft.Azure.Gallery;
1818
using Microsoft.Azure.Management.Resources;
1919
using Microsoft.Azure.Management.WebSites;
20-
using Microsoft.Azure.Commands.Websites.Utilities;
20+
using Microsoft.Azure.Commands.WebApp.Utilities;
2121
using Microsoft.Azure.Subscriptions;
2222
using Microsoft.Azure.Test.HttpRecorder;
2323
using Microsoft.WindowsAzure.Commands.ScenarioTest;
@@ -26,7 +26,7 @@
2626
using System;
2727
using System.Linq;
2828

29-
namespace Microsoft.Azure.Commands.Websites.Test.ScenarioTests
29+
namespace Microsoft.Azure.Commands.WebApp.Test.ScenarioTests
3030
{
3131
public class WebsitesController
3232
{

src/ResourceManager/Websites/Commands.Websites.Test/SessionRecords/Microsoft.Azure.Commands.WebApp.Test.ScenarioTests.WebAppTests/TestCreatesNewAppServicePlan.json

Lines changed: 742 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/Websites/Commands.Websites.Test/SessionRecords/Microsoft.Azure.Commands.WebApp.Test.ScenarioTests.WebAppTests/TestCreatesNewSimpleWebApp.json

Lines changed: 1208 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/Websites/Commands.Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebsitesTests/TestCreatesNewSimpleWebsite.json

Lines changed: 0 additions & 980 deletions
This file was deleted.

src/ResourceManager/Websites/Commands.Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebsitesTests/TestCreatesNewWebHostingPlan.json

Lines changed: 0 additions & 742 deletions
This file was deleted.

src/ResourceManager/Websites/Commands.Websites.Test/packages.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
77
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
88
<package id="Microsoft.Azure.Management.Authorization" version="0.17.0-preview" targetFramework="net45" />
9+
<package id="Microsoft.Azure.Management.Resources" version="2.13.0-preview" targetFramework="net45" />
10+
<package id="Microsoft.Azure.Management.WebSites" version="0.16.4-prerelease" targetFramework="net45" />
911
<package id="Microsoft.Azure.Management.Resources" version="2.14.1-preview" targetFramework="net45" />
1012
<package id="Microsoft.Azure.Management.WebSites" version="0.16.1-prerelease" targetFramework="net45" />
1113
<package id="Microsoft.Azure.Test.Framework" version="1.0.5513.27084-prerelease" targetFramework="net45" />

src/ResourceManager/Websites/Commands.Websites/Cmdlets/WebHostingPlan/ListAzureWebHostingPlan.cs renamed to src/ResourceManager/Websites/Commands.Websites/Cmdlets/AppServicePlan/GetAzureAppServicePlan.cs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,47 @@
2222
using Microsoft.Azure.Management.WebSites.Models;
2323
using Microsoft.WindowsAzure;
2424
using Microsoft.WindowsAzure.Commands.Utilities.CloudService;
25-
using Microsoft.Azure.Commands.Websites;
25+
using Microsoft.Azure.Commands.WebApp;
2626
using Microsoft.Azure.Management.WebSites;
2727
using System.Net.Http;
2828
using System.Threading;
2929
using Microsoft.IdentityModel.Clients.ActiveDirectory;
3030
using System.Net;
3131
using Microsoft.Azure;
3232
using Microsoft.WindowsAzure.Commands.Utilities.Common;
33-
using Microsoft.Azure.Commands.Websites.Utilities;
34-
using Microsoft.Azure.Commands.Websites.Models.Websites;
33+
using Microsoft.Azure.Commands.WebApp.Utilities;
3534

3635

37-
namespace Microsoft.Azure.Commands.Websites.Cmdlets.WebHostingPlan
36+
namespace Microsoft.Azure.Commands.WebApp.Cmdlets.AppServicePlan
3837
{
3938
/// <summary>
40-
/// this commandlet will let you delete an Azure Web Hosting Plan using ARM APIs
39+
/// this commandlet will let you Get an Azure App Service Plan using ARM APIs
4140
/// </summary>
42-
[Cmdlet(VerbsCommon.Get, "AzureWebHostingPlans"), OutputType(typeof(WebHostingPlanListResponse))]
43-
public class ListWebHostingPlanCmdlet : WebsitesBaseClient
41+
[Cmdlet(VerbsCommon.Get, "AzureAppServicePlan"), OutputType(typeof(WebHostingPlanGetResponse), typeof(WebHostingPlanListResponse))]
42+
public class GetAppServicePlanCmdlet : WebHostingPlanBaseNotMandatoryCmdlet
4443
{
45-
[Parameter(Position = 0, Mandatory = true, HelpMessage = "The name of the resource group.")]
46-
[ValidateNotNullOrEmptyAttribute]
47-
public string ResourceGroupName { get; set; }
48-
4944
public override void ExecuteCmdlet()
5045
{
51-
WriteObject(WebsitesClient.ListWebHostingPlan(ResourceGroupName));
46+
if (!string.IsNullOrEmpty(ResourceGroupName) && !string.IsNullOrEmpty(Name))
47+
{
48+
GetByWebHostingPlan();
49+
}
50+
else if (!string.IsNullOrEmpty(ResourceGroupName))
51+
{
52+
GetByResourceGroup();
53+
}
54+
55+
}
5256

57+
private void GetByWebHostingPlan()
58+
{
59+
WriteObject(WebsitesClient.GetWebHostingPlan(ResourceGroupName, Name));
5360
}
5461

62+
private void GetByResourceGroup()
63+
{
64+
WriteObject(WebsitesClient.ListWebHostingPlan(ResourceGroupName));
65+
}
5566
}
5667
}
5768

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
16+
using System;
17+
using System.Collections.Generic;
18+
using System.Linq;
19+
using System.Text;
20+
using System.Threading.Tasks;
21+
using System.Management.Automation;
22+
using Microsoft.Azure.Management.WebSites.Models;
23+
using Microsoft.WindowsAzure;
24+
using Microsoft.WindowsAzure.Commands.Utilities.CloudService;
25+
using Microsoft.Azure.Commands.WebApp;
26+
using Microsoft.Azure.Management.WebSites;
27+
using System.Net.Http;
28+
using System.Threading;
29+
using Microsoft.IdentityModel.Clients.ActiveDirectory;
30+
using System.Net;
31+
using Microsoft.Azure;
32+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
33+
using Microsoft.Azure.Commands.WebApp.Utilities;
34+
35+
namespace Microsoft.Azure.Commands.WebApp.Cmdlets.AppServicePlan
36+
{
37+
/// <summary>
38+
/// this commandlet will let you get metrics of an app service plan using ARM APIs
39+
/// </summary>
40+
[Cmdlet(VerbsCommon.Get, "AzureAppServicePlanMetrics"), OutputType(typeof(WebHostingPlanCreateOrUpdateResponse))]
41+
public class GetAzureAppServicePlanMetricsCmdlet : AppServicePlanBaseCmdlet
42+
{
43+
[Parameter(Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "List of metrics names to retrieve.")]
44+
[ValidateNotNullOrEmpty]
45+
public string [] Metrics { get; set; }
46+
47+
[Parameter(Position = 3, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Granularity.")]
48+
[ValidateSet("Minutes", "Hours", "Days", IgnoreCase = true)]
49+
[ValidateNotNullOrEmpty]
50+
public string Granularity { get; set; }
51+
52+
[Parameter(Position = 4, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The start time.")]
53+
[ValidateNotNullOrEmpty]
54+
public DateTime? StartDate { get; set; }
55+
56+
[Parameter(Position = 5, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The end time.")]
57+
public DateTime? EndDate { get; set; }
58+
59+
[Parameter(Position = 6, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Include details for each server instance in the web hosting plan.")]
60+
public SwitchParameter InstanceDetails { get; set; }
61+
62+
[Parameter(Position = 7, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Time grain for the metrics. Supported values are PT1M (per minute), PT1H (per hour), P1D (per day).")]
63+
[ValidateSet("PT1M", "PT1H", "P1D", IgnoreCase = true)]
64+
public string TimeGrain { get; set; }
65+
66+
67+
public override void ExecuteCmdlet()
68+
{
69+
WebHostingPlanGetHistoricalUsageMetricsResponse response = WebsitesClient.GetAppServicePlanHistoricalUsageMetrics(ResourceGroupName, Name, Metrics, StartDate, EndDate, TimeGrain, InstanceDetails);
70+
foreach (var metricResponse in response.UsageMetrics)
71+
{
72+
WriteObject(metricResponse, true);
73+
}
74+
}
75+
76+
}
77+
}

0 commit comments

Comments
 (0)