Skip to content

Commit df9a0ce

Browse files
committed
Merge pull request #154 from NaveenGoli/dev
Initial commit for the Websites commandlets for ARM
2 parents b190035 + 3072a19 commit df9a0ce

19 files changed

+1014
-2
lines changed

src/AzurePowershell.sln

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 2013
3-
VisualStudioVersion = 12.0.30723.0
3+
VisualStudioVersion = 12.0.31101.0
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8531411A-0137-4E27-9C5E-49E07C245048}"
66
ProjectSection(SolutionItems) = preProject
@@ -163,6 +163,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Insights", "Resour
163163
EndProject
164164
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Insights.Test", "ResourceManager\Insights\Commands.Insights.Test\Commands.Insights.Test.csproj", "{469F20E0-9D40-41AD-94C3-B47AD15A4C00}"
165165
EndProject
166+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Websites", "ResourceManager\Websites\Commands.Websites\Commands.Websites.csproj", "{80A92297-7C92-456B-8EE7-9FB6CE30149D}"
167+
EndProject
166168
Global
167169
GlobalSection(SolutionConfigurationPlatforms) = preSolution
168170
Debug|Any CPU = Debug|Any CPU
@@ -397,6 +399,10 @@ Global
397399
{469F20E0-9D40-41AD-94C3-B47AD15A4C00}.Debug|Any CPU.Build.0 = Debug|Any CPU
398400
{469F20E0-9D40-41AD-94C3-B47AD15A4C00}.Release|Any CPU.ActiveCfg = Release|Any CPU
399401
{469F20E0-9D40-41AD-94C3-B47AD15A4C00}.Release|Any CPU.Build.0 = Release|Any CPU
402+
{80A92297-7C92-456B-8EE7-9FB6CE30149D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
403+
{80A92297-7C92-456B-8EE7-9FB6CE30149D}.Debug|Any CPU.Build.0 = Debug|Any CPU
404+
{80A92297-7C92-456B-8EE7-9FB6CE30149D}.Release|Any CPU.ActiveCfg = Release|Any CPU
405+
{80A92297-7C92-456B-8EE7-9FB6CE30149D}.Release|Any CPU.Build.0 = Release|Any CPU
400406
EndGlobalSection
401407
GlobalSection(SolutionProperties) = preSolution
402408
HideSolutionNode = FALSE

src/ResourceManager/Resources/Commands.Resources/AzureResourceManager.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ NestedModules = @(
7979
'.\Batch\Microsoft.Azure.Commands.Batch.dll',
8080
'.\KeyVault\Microsoft.Azure.Commands.KeyVault.dll',
8181
'.\StreamAnalytics\Microsoft.Azure.Commands.StreamAnalytics.dll',
82-
'.\Insights\Microsoft.Azure.Commands.Insights.dll'
82+
'.\Insights\Microsoft.Azure.Commands.Insights.dll',
83+
'.\Websites\Microsoft.Azure.Commands.Websites.dll'
8384
)
8485

8586
# Functions to export from this module

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@
264264
<Project>{F49A314A-A235-47D3-A654-1EC19ACA366C}</Project>
265265
<Name>Commands.StreamAnalytics</Name>
266266
</ProjectReference>
267+
<ProjectReference Include="..\..\Websites\Commands.Websites\Commands.Websites.csproj">
268+
<Project>{80a92297-7c92-456b-8ee7-9fb6ce30149d}</Project>
269+
<Name>Commands.Websites</Name>
270+
</ProjectReference>
267271
</ItemGroup>
268272
<ItemGroup>
269273
<Content Include="Microsoft.Azure.Commands.Resources.dll-Help.xml">
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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.Websites;
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.Websites.Utilities;
34+
35+
36+
namespace Microsoft.Azure.Commands.Websites.Cmdlets
37+
{
38+
/// <summary>
39+
/// this commandlet will let you create a new Azure Websites using ARM APIs
40+
/// </summary>
41+
[Cmdlet(VerbsCommon.New, "AzureWebsite")]
42+
public class NewAzureWebsiteCmdlet : WebsiteBaseCmdlet
43+
{
44+
45+
[Parameter(Position = 2, Mandatory = false, HelpMessage = "The name of the website slot.")]
46+
[ValidateNotNullOrEmptyAttribute]
47+
public string SlotName { get; set; }
48+
49+
[Parameter(Position = 3, Mandatory = true, HelpMessage = "The Location of the Website eg: West US.")]
50+
public string Location { get; set; }
51+
52+
[Parameter(Position = 4, Mandatory = true, HelpMessage = "The name of the web hosting plan eg: Default1.")]
53+
public string WebHostingPlan { get; set; }
54+
55+
public override void ExecuteCmdlet()
56+
{
57+
WriteObject(WebsitesClient.CreateWebsite(ResourceGroupName, WebsiteName, SlotName, Location, WebHostingPlan));
58+
59+
}
60+
61+
}
62+
}
63+
64+
65+
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
using Microsoft.WindowsAzure.Commands.Utilities.Properties;
36+
37+
38+
namespace Microsoft.Azure.Commands.Websites.Cmdlets
39+
{
40+
/// <summary>
41+
/// this commandlet will let you delete an Azure website
42+
/// </summary>
43+
[Cmdlet(VerbsCommon.Remove, "AzureWebsite")]
44+
public class RemoveAzureWebsiteCmdlet : WebsiteBaseCmdlet
45+
{
46+
47+
//always delete the slots,
48+
private bool deleteSlotsByDefault = true;
49+
50+
// leave behind the empty webhosting plan
51+
private bool deleteEmptyServerFarmByDefault = false;
52+
53+
//always delete the metrics
54+
private bool deleteMetricsByDefault = true;
55+
56+
[Parameter(Mandatory = false, HelpMessage = "Do not ask for confirmation.")]
57+
public SwitchParameter Force { get; set; }
58+
59+
public override void ExecuteCmdlet()
60+
{
61+
string slotName = null;
62+
63+
ConfirmAction(
64+
Force.IsPresent,
65+
string.Format(Resources.RemoveWebsiteWarning, WebsiteName),
66+
Resources.RemoveWebsiteMessage,
67+
WebsiteName,
68+
() => WebsitesClient.RemoveWebsite(ResourceGroupName, WebsiteName, slotName, deleteEmptyServerFarmByDefault, deleteMetricsByDefault, deleteSlotsByDefault));
69+
}
70+
71+
}
72+
}
73+
74+
75+
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 let you restart an Azure Website
41+
/// </summary>
42+
[Cmdlet(VerbsLifecycle.Restart, "AzureWebsite")]
43+
public class RestartAzureWebsiteCmdlet : WebsiteBaseCmdlet
44+
{
45+
46+
[Parameter(Position = 2, Mandatory = false, HelpMessage = "The name of the website slot.")]
47+
[ValidateNotNullOrEmptyAttribute]
48+
public string SlotName { get; set; }
49+
50+
public override void ExecuteCmdlet()
51+
{
52+
WriteObject(WebsitesClient.RestartWebsite(ResourceGroupName, WebsiteName, SlotName));
53+
}
54+
55+
}
56+
}
57+
58+
59+
60+
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 let you Start an Azure Website
41+
/// </summary>
42+
[Cmdlet(VerbsLifecycle.Start, "AzureWebsite")]
43+
public class StartAzureWebsiteCmdlet : WebsiteBaseCmdlet
44+
{
45+
46+
[Parameter(Position = 2, Mandatory = false, HelpMessage = "The name of the website slot.")]
47+
[ValidateNotNullOrEmptyAttribute]
48+
public string SlotName { get; set; }
49+
50+
public override void ExecuteCmdlet()
51+
{
52+
WriteObject(WebsitesClient.StartWebsite(ResourceGroupName, WebsiteName, SlotName));
53+
54+
}
55+
56+
}
57+
}
58+
59+
60+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 let you stop an Azure Website
41+
/// </summary>
42+
[Cmdlet(VerbsLifecycle.Stop, "AzureWebsite")]
43+
public class StopAzureWebsiteCmdlet : WebsiteBaseCmdlet
44+
{
45+
46+
[Parameter(Position = 2, Mandatory = false, HelpMessage = "The name of the website slot.")]
47+
[ValidateNotNullOrEmptyAttribute]
48+
public string SlotName { get; set; }
49+
50+
public override void ExecuteCmdlet()
51+
{
52+
WriteObject(WebsitesClient.StopWebsite(ResourceGroupName, WebsiteName, SlotName));
53+
}
54+
55+
}
56+
}
57+
58+
59+

0 commit comments

Comments
 (0)