Skip to content

Commit 81cfe93

Browse files
committed
Merge pull request #268 from NaveenGoli/save-branch
Changed the parameter WebsiteName to Name to use in piping. Added publis...
2 parents c861be4 + cef1fef commit 81cfe93

File tree

16 files changed

+525
-268
lines changed

16 files changed

+525
-268
lines changed

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebsitesTests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ function Test-CreatesNewSimpleWebsite
3232
New-AzureWebHostingPlan -ResourceGroupName $rgname -WebHostingPlanName $whpName -location $location
3333

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

3838
# Assert
3939
Assert-AreEqual $wname $result.Name
@@ -42,7 +42,7 @@ function Test-CreatesNewSimpleWebsite
4242
finally
4343
{
4444
# Cleanup
45-
Remove-AzureWebsite -ResourceGroupName $rgname -WebsiteName $wname -Force
45+
Remove-AzureWebsite -ResourceGroupName $rgname -Name $wname -Force
4646
Remove-AzureWebHostingPlan -ResourceGroupName $rgname -WebHostingPlanName $whpName -Force
4747
Remove-AzureResourceGroup -Name $rgname -Force
4848
}

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

Lines changed: 246 additions & 132 deletions
Large diffs are not rendered by default.

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

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

src/ResourceManager/Websites/Commands.Websites/Cmdlets/GetAzureWebsite.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,11 @@ namespace Microsoft.Azure.Commands.Websites.Cmdlets
4040
/// this commandlet will let you create a new Azure Websites using ARM APIs
4141
/// </summary>
4242
[Cmdlet(VerbsCommon.Get, "AzureWebsite")]
43-
public class GetAzureWebsiteCmdlet : WebsiteBaseCmdlet
43+
public class GetAzureWebsiteCmdlet : WebsiteBaseSlotCmdlet
4444
{
45-
46-
[Parameter(Position = 2, Mandatory = false, HelpMessage = "The name of the website slot.")]
47-
[ValidateNotNullOrEmptyAttribute]
48-
public string SlotName { get; set; }
49-
5045
public override void ExecuteCmdlet()
5146
{
52-
WriteObject(WebsitesClient.GetWebsite(ResourceGroupName, WebsiteName, SlotName));
47+
WriteObject(WebsitesClient.GetWebsite(ResourceGroupName, Name, SlotName));
5348

5449
}
5550

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+

2+
// ----------------------------------------------------------------------------------
3+
//
4+
// Copyright Microsoft Corporation
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
// ----------------------------------------------------------------------------------
15+
16+
17+
using System;
18+
using System.Collections.Generic;
19+
using System.Linq;
20+
using System.Text;
21+
using System.Threading.Tasks;
22+
using System.Management.Automation;
23+
using Microsoft.Azure.Management.WebSites.Models;
24+
using Microsoft.WindowsAzure;
25+
using Microsoft.WindowsAzure.Commands.Utilities.CloudService;
26+
using Microsoft.Azure.Commands.Websites;
27+
using Microsoft.Azure.Management.WebSites;
28+
using System.Net.Http;
29+
using System.Threading;
30+
using Microsoft.IdentityModel.Clients.ActiveDirectory;
31+
using System.Net;
32+
using Microsoft.Azure;
33+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
34+
using Microsoft.Azure.Commands.Websites.Utilities;
35+
36+
37+
namespace Microsoft.Azure.Commands.Websites.Cmdlets
38+
{
39+
/// <summary>
40+
/// this commandlet will get the publishing creds of the given Azure Websites using ARM APIs
41+
/// </summary>
42+
[Cmdlet(VerbsCommon.Get, "AzureWebsitePublishingProfile")]
43+
public class GetAzureWebsitePublishingProfileCmdlet : WebsiteBaseSlotCmdlet
44+
{
45+
public override void ExecuteCmdlet()
46+
{
47+
WriteObject(WebsitesClient.GetWebsitePublishingProfile(ResourceGroupName, Name, SlotName));
48+
49+
}
50+
51+
}
52+
}
53+
54+
55+

src/ResourceManager/Websites/Commands.Websites/Cmdlets/NewAzureWebsites.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class NewAzureWebsiteCmdlet : WebsiteBaseCmdlet
5454

5555
public override void ExecuteCmdlet()
5656
{
57-
WriteObject(WebsitesClient.CreateWebsite(ResourceGroupName, WebsiteName, SlotName, Location, WebHostingPlan));
57+
WriteObject(WebsitesClient.CreateWebsite(ResourceGroupName, Name, SlotName, Location, WebHostingPlan));
5858

5959
}
6060

src/ResourceManager/Websites/Commands.Websites/Cmdlets/RemoveAzureWebsite.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace Microsoft.Azure.Commands.Websites.Cmdlets
4141
/// this commandlet will let you delete an Azure website
4242
/// </summary>
4343
[Cmdlet(VerbsCommon.Remove, "AzureWebsite")]
44-
public class RemoveAzureWebsiteCmdlet : WebsiteBaseCmdlet
44+
public class RemoveAzureWebsiteCmdlet : WebsiteBaseNotMandatoryCmdlet
4545
{
4646

4747
//always delete the slots,
@@ -58,14 +58,15 @@ public class RemoveAzureWebsiteCmdlet : WebsiteBaseCmdlet
5858

5959
public override void ExecuteCmdlet()
6060
{
61+
// Currently we delete all slots.
6162
string slotName = null;
6263

6364
ConfirmAction(
6465
Force.IsPresent,
65-
string.Format(Resources.RemoveWebsiteWarning, WebsiteName),
66+
string.Format(Resources.RemoveWebsiteWarning, Name),
6667
Resources.RemoveWebsiteMessage,
67-
WebsiteName,
68-
() => WebsitesClient.RemoveWebsite(ResourceGroupName, WebsiteName, slotName, deleteEmptyServerFarmByDefault, deleteMetricsByDefault, deleteSlotsByDefault));
68+
Name,
69+
() => WebsitesClient.RemoveWebsite(ResourceGroupName, Name, slotName, deleteEmptyServerFarmByDefault, deleteMetricsByDefault, deleteSlotsByDefault));
6970
}
7071

7172
}

src/ResourceManager/Websites/Commands.Websites/Cmdlets/RestartAzureWebsite.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class RestartAzureWebsiteCmdlet : WebsiteBaseCmdlet
4949

5050
public override void ExecuteCmdlet()
5151
{
52-
WriteObject(WebsitesClient.RestartWebsite(ResourceGroupName, WebsiteName, SlotName));
52+
WriteObject(WebsitesClient.RestartWebsite(ResourceGroupName, Name, SlotName));
5353
}
5454

5555
}

src/ResourceManager/Websites/Commands.Websites/Cmdlets/StartAzureWebsite.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class StartAzureWebsiteCmdlet : WebsiteBaseCmdlet
4949

5050
public override void ExecuteCmdlet()
5151
{
52-
WriteObject(WebsitesClient.StartWebsite(ResourceGroupName, WebsiteName, SlotName));
52+
WriteObject(WebsitesClient.StartWebsite(ResourceGroupName, Name, SlotName));
5353

5454
}
5555

src/ResourceManager/Websites/Commands.Websites/Cmdlets/StopAzureWebsite.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class StopAzureWebsiteCmdlet : WebsiteBaseCmdlet
4949

5050
public override void ExecuteCmdlet()
5151
{
52-
WriteObject(WebsitesClient.StopWebsite(ResourceGroupName, WebsiteName, SlotName));
52+
WriteObject(WebsitesClient.StopWebsite(ResourceGroupName, Name, SlotName));
5353
}
5454

5555
}

src/ResourceManager/Websites/Commands.Websites/Cmdlets/WebHostingPlan/NewAzureWebHostingPlan.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class NewAzureWebHostingPlanCmdlet : WebHostingPlanBaseCmdlet
5454
[ValidateNotNullOrEmptyAttribute]
5555
public int NumberofWorkers { get; set; }
5656

57-
[Parameter(Position = 5, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The size of he workers: eg Small, Medium, Large")]
57+
[Parameter(Position = 5, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The size of the workers: eg Small, Medium, Large")]
5858
[ValidateNotNullOrEmptyAttribute]
5959
[ValidateSet("Small", "Medium", "Large", IgnoreCase = true)]
6060
public string WorkerSize { get; set; }

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
125125
</ItemGroup>
126126
<ItemGroup>
127+
<Compile Include="Cmdlets\GetAzureWebsitePublishingProfile .cs" />
127128
<Compile Include="Cmdlets\GetAzureWebsite.cs" />
128129
<Compile Include="Cmdlets\RemoveAzureWebsite.cs" />
129130
<Compile Include="Cmdlets\NewAzureWebsites.cs" />
@@ -136,6 +137,8 @@
136137
<Compile Include="Cmdlets\WebHostingPlan\NewAzureWebHostingPlan.cs" />
137138
<Compile Include="Cmdlets\WebHostingPlan\RemoveWebHostingPlan.cs" />
138139
<Compile Include="Models.Websites\WebHostingPlanBaseCmdlet.cs" />
140+
<Compile Include="Models.Websites\WebsiteBaseNotMandatoryCmdlet.cs" />
141+
<Compile Include="Models.Websites\WebsiteBaseSlotCmdlet.cs" />
139142
<Compile Include="Models.Websites\WebsiteBaseCmdlet.cs" />
140143
<Compile Include="Models.Websites\WebsitesBaseClient.cs" />
141144
<Compile Include="Utilities\WebsitesClient.cs" />

src/ResourceManager/Websites/Commands.Websites/Models.Websites/WebsiteBaseCmdlet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class WebsiteBaseCmdlet : WebsitesBaseClient
2626

2727
[Parameter(Position = 1, Mandatory = true, HelpMessage = "The name of the website.")]
2828
[ValidateNotNullOrEmptyAttribute]
29-
public string WebsiteName { get; set; }
29+
public string Name { get; set; }
3030
}
3131
}
3232

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
using Microsoft.Azure.Commands.Websites.Models;
16+
using System.Management.Automation;
17+
using Microsoft.Azure.Commands.Websites.Models.Websites;
18+
19+
namespace Microsoft.Azure.Commands.Websites
20+
{
21+
public class WebsiteBaseNotMandatoryCmdlet : WebsitesBaseClient
22+
{
23+
[Parameter(Position = 0, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the resource group.")]
24+
[ValidateNotNullOrEmptyAttribute]
25+
public string ResourceGroupName { get; set; }
26+
27+
[Parameter(Position = 1, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the website.")]
28+
[ValidateNotNullOrEmptyAttribute]
29+
public string Name { get; set; }
30+
}
31+
}
32+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
using Microsoft.Azure.Commands.Websites.Models;
16+
using System.Management.Automation;
17+
using Microsoft.Azure.Commands.Websites.Models.Websites;
18+
19+
namespace Microsoft.Azure.Commands.Websites
20+
{
21+
public class WebsiteBaseSlotCmdlet : WebsitesBaseClient
22+
{
23+
[Parameter(Position = 0, Mandatory = true, HelpMessage = "The name of the resource group.")]
24+
[ValidateNotNullOrEmptyAttribute]
25+
public string ResourceGroupName { get; set; }
26+
27+
[Parameter(Position = 1, Mandatory = true, HelpMessage = "The name of the website.")]
28+
[ValidateNotNullOrEmptyAttribute]
29+
public string Name { get; set; }
30+
31+
[Parameter(Position = 2, Mandatory = false, HelpMessage = "The name of the website slot.")]
32+
[ValidateNotNullOrEmptyAttribute]
33+
public string SlotName { get; set; }
34+
}
35+
}
36+

src/ResourceManager/Websites/Commands.Websites/Utilities/WebsitesClient.cs

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,58 +92,79 @@ public System.Net.HttpStatusCode RemoveWebsite(string resourceGroupName, string
9292
public WebSite GetWebsite(string resourceGroupName, string webSiteName, string slotName)
9393
{
9494
WebSiteGetParameters webSiteGetParams = new WebSiteGetParameters();
95-
9695
var getWebsite = WrappedWebsitesClient.WebSites.Get(resourceGroupName, webSiteName, slotName, webSiteGetParams);
96+
try
97+
{
98+
var getAppSettings = WrappedWebsitesClient.WebSites.GetAppSettings(resourceGroupName, webSiteName, slotName);
99+
//Add websiteApp Settings to the Website object as the Get call will not return them.
100+
foreach (var appSettingVal in getAppSettings.Resource.Properties.ToList())
101+
{
102+
if (!getWebsite.WebSite.Properties.Properties.AppSettings.Keys.Contains(appSettingVal.Name))
103+
getWebsite.WebSite.Properties.Properties.AppSettings.Add(appSettingVal.Name, appSettingVal.Value);
104+
}
105+
}
106+
catch
107+
{
108+
//ignore if this call fails as it will for reader RBAC
109+
}
110+
//Add ConnectionStrings Settings to the Website object as the Get call will not return them.
111+
112+
try
113+
{
114+
var getConnectionStringsSettings = WrappedWebsitesClient.WebSites.GetConnectionStrings(resourceGroupName, webSiteName, slotName);
115+
//TODO: Add ConnectionStrings Settings to the Website object as the Get call will not return them.
116+
117+
118+
}
119+
catch
120+
{
121+
//ignore if this call fails as it will for reader RBAC
122+
}
123+
97124
return getWebsite.WebSite;
98125
}
99126

127+
public WebSiteGetPublishProfileResponse GetWebsitePublishingProfile(string resourceGroupName, string webSiteName, string slotName)
128+
{
129+
var pubCreds = WrappedWebsitesClient.WebSites.GetPublishProfile(resourceGroupName, webSiteName, slotName);
130+
return pubCreds;
131+
}
100132

101133
public WebHostingPlanCreateOrUpdateResponse CreateWebHostingPlan(string resourceGroupName, string whpName, string location, string adminSiteName, int numberOfWorkers, SkuOptions sku, WorkerSizeOptions workerSize)
102134
{
103-
104-
105135
WebHostingPlanProperties webHostingPlanProperties = new WebHostingPlanProperties();
106136
webHostingPlanProperties.Sku = sku;
107137
webHostingPlanProperties.AdminSiteName = adminSiteName;
108138
webHostingPlanProperties.NumberOfWorkers = numberOfWorkers;
109139
webHostingPlanProperties.WorkerSize = workerSize;
110-
111-
WebHostingPlan webHostingPlan = new WebHostingPlan();
112-
140+
WebHostingPlan webHostingPlan = new WebHostingPlan();
113141
WebHostingPlanCreateOrUpdateParameters webHostingPlanCreateOrUpdateParameters = new WebHostingPlanCreateOrUpdateParameters(webHostingPlan);
114142
webHostingPlanCreateOrUpdateParameters.WebHostingPlan.Location = location;
115143
webHostingPlanCreateOrUpdateParameters.WebHostingPlan.Name = whpName;
116144
webHostingPlanCreateOrUpdateParameters.WebHostingPlan.Properties = webHostingPlanProperties;
117145

118146
var createdWHP = WrappedWebsitesClient.WebHostingPlans.CreateOrUpdate(resourceGroupName, webHostingPlanCreateOrUpdateParameters);
119-
120147
//proper return type need to be discussed
121148
return createdWHP;
122149
}
123150

124151
public AzureOperationResponse RemoveWebHostingPlan(string resourceGroupName, string whpName)
125152
{
126-
127153
var response = WrappedWebsitesClient.WebHostingPlans.Delete(resourceGroupName, whpName);
128-
129154
//proper return type need to be discussed
130155
return response;
131156
}
132157

133158
public WebHostingPlanGetResponse GetWebHostingPlan(string resourceGroupName, string whpName)
134159
{
135-
136160
var response = WrappedWebsitesClient.WebHostingPlans.Get(resourceGroupName, whpName);
137-
138161
//proper return type need to be discussed
139162
return response;
140163
}
141164

142165
public WebHostingPlanListResponse ListWebHostingPlan(string resourceGroupName)
143-
{
144-
166+
{
145167
var response = WrappedWebsitesClient.WebHostingPlans.List(resourceGroupName);
146-
147168
//proper return type need to be discussed
148169
return response;
149170
}

0 commit comments

Comments
 (0)