diff --git a/src/AzurePowershell.sln b/src/AzurePowershell.sln index 8be43bf6ad2e..3d1828d1a877 100644 --- a/src/AzurePowershell.sln +++ b/src/AzurePowershell.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.30723.0 +VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8531411A-0137-4E27-9C5E-49E07C245048}" ProjectSection(SolutionItems) = preProject @@ -163,6 +163,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Insights", "Resour EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Insights.Test", "ResourceManager\Insights\Commands.Insights.Test\Commands.Insights.Test.csproj", "{469F20E0-9D40-41AD-94C3-B47AD15A4C00}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Websites", "ResourceManager\Websites\Commands.Websites\Commands.Websites.csproj", "{80A92297-7C92-456B-8EE7-9FB6CE30149D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -397,6 +399,10 @@ Global {469F20E0-9D40-41AD-94C3-B47AD15A4C00}.Debug|Any CPU.Build.0 = Debug|Any CPU {469F20E0-9D40-41AD-94C3-B47AD15A4C00}.Release|Any CPU.ActiveCfg = Release|Any CPU {469F20E0-9D40-41AD-94C3-B47AD15A4C00}.Release|Any CPU.Build.0 = Release|Any CPU + {80A92297-7C92-456B-8EE7-9FB6CE30149D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {80A92297-7C92-456B-8EE7-9FB6CE30149D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {80A92297-7C92-456B-8EE7-9FB6CE30149D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {80A92297-7C92-456B-8EE7-9FB6CE30149D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/ResourceManager/Resources/Commands.Resources/AzureResourceManager.psd1 b/src/ResourceManager/Resources/Commands.Resources/AzureResourceManager.psd1 index e8ac25f5fb5f..d5773eacf5b6 100644 --- a/src/ResourceManager/Resources/Commands.Resources/AzureResourceManager.psd1 +++ b/src/ResourceManager/Resources/Commands.Resources/AzureResourceManager.psd1 @@ -79,7 +79,8 @@ NestedModules = @( '.\Batch\Microsoft.Azure.Commands.Batch.dll', '.\KeyVault\Microsoft.Azure.Commands.KeyVault.dll', '.\StreamAnalytics\Microsoft.Azure.Commands.StreamAnalytics.dll', - '.\Insights\Microsoft.Azure.Commands.Insights.dll' + '.\Insights\Microsoft.Azure.Commands.Insights.dll', + '.\Websites\Microsoft.Azure.Commands.Websites.dll' ) # Functions to export from this module diff --git a/src/ResourceManager/Resources/Commands.Resources/Commands.Resources.csproj b/src/ResourceManager/Resources/Commands.Resources/Commands.Resources.csproj index 1866b0860e5f..b9587bcec5fe 100644 --- a/src/ResourceManager/Resources/Commands.Resources/Commands.Resources.csproj +++ b/src/ResourceManager/Resources/Commands.Resources/Commands.Resources.csproj @@ -264,6 +264,10 @@ {F49A314A-A235-47D3-A654-1EC19ACA366C} Commands.StreamAnalytics + + {80a92297-7c92-456b-8ee7-9fb6ce30149d} + Commands.Websites + diff --git a/src/ResourceManager/Websites/Commands.Websites/Cmdlets/NewAzureWebsites.cs b/src/ResourceManager/Websites/Commands.Websites/Cmdlets/NewAzureWebsites.cs new file mode 100644 index 000000000000..bebc4063fd50 --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/Cmdlets/NewAzureWebsites.cs @@ -0,0 +1,65 @@ +// ---------------------------------------------------------------------------------- +// +// 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 System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Management.Automation; +using Microsoft.Azure.Management.WebSites.Models; +using Microsoft.WindowsAzure; +using Microsoft.WindowsAzure.Commands.Utilities.CloudService; +using Microsoft.Azure.Commands.Websites; +using Microsoft.Azure.Management.WebSites; +using System.Net.Http; +using System.Threading; +using Microsoft.IdentityModel.Clients.ActiveDirectory; +using System.Net; +using Microsoft.Azure; +using Microsoft.WindowsAzure.Commands.Utilities.Common; +using Microsoft.Azure.Commands.Websites.Utilities; + + +namespace Microsoft.Azure.Commands.Websites.Cmdlets +{ + /// + /// this commandlet will let you create a new Azure Websites using ARM APIs + /// + [Cmdlet(VerbsCommon.New, "AzureWebsite")] + public class NewAzureWebsiteCmdlet : WebsiteBaseCmdlet + { + + [Parameter(Position = 2, Mandatory = false, HelpMessage = "The name of the website slot.")] + [ValidateNotNullOrEmptyAttribute] + public string SlotName { get; set; } + + [Parameter(Position = 3, Mandatory = true, HelpMessage = "The Location of the Website eg: West US.")] + public string Location { get; set; } + + [Parameter(Position = 4, Mandatory = true, HelpMessage = "The name of the web hosting plan eg: Default1.")] + public string WebHostingPlan { get; set; } + + public override void ExecuteCmdlet() + { + WriteObject(WebsitesClient.CreateWebsite(ResourceGroupName, WebsiteName, SlotName, Location, WebHostingPlan)); + + } + + } +} + + + diff --git a/src/ResourceManager/Websites/Commands.Websites/Cmdlets/RemoveAzureWebsite.cs b/src/ResourceManager/Websites/Commands.Websites/Cmdlets/RemoveAzureWebsite.cs new file mode 100644 index 000000000000..77cc21df053b --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/Cmdlets/RemoveAzureWebsite.cs @@ -0,0 +1,75 @@ + +// ---------------------------------------------------------------------------------- +// +// 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 System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Management.Automation; +using Microsoft.Azure.Management.WebSites.Models; +using Microsoft.WindowsAzure; +using Microsoft.WindowsAzure.Commands.Utilities.CloudService; +using Microsoft.Azure.Commands.Websites; +using Microsoft.Azure.Management.WebSites; +using System.Net.Http; +using System.Threading; +using Microsoft.IdentityModel.Clients.ActiveDirectory; +using System.Net; +using Microsoft.Azure; +using Microsoft.WindowsAzure.Commands.Utilities.Common; +using Microsoft.Azure.Commands.Websites.Utilities; +using Microsoft.WindowsAzure.Commands.Utilities.Properties; + + +namespace Microsoft.Azure.Commands.Websites.Cmdlets +{ + /// + /// this commandlet will let you delete an Azure website + /// + [Cmdlet(VerbsCommon.Remove, "AzureWebsite")] + public class RemoveAzureWebsiteCmdlet : WebsiteBaseCmdlet + { + + //always delete the slots, + private bool deleteSlotsByDefault = true; + + // leave behind the empty webhosting plan + private bool deleteEmptyServerFarmByDefault = false; + + //always delete the metrics + private bool deleteMetricsByDefault = true; + + [Parameter(Mandatory = false, HelpMessage = "Do not ask for confirmation.")] + public SwitchParameter Force { get; set; } + + public override void ExecuteCmdlet() + { + string slotName = null; + + ConfirmAction( + Force.IsPresent, + string.Format(Resources.RemoveWebsiteWarning, WebsiteName), + Resources.RemoveWebsiteMessage, + WebsiteName, + () => WebsitesClient.RemoveWebsite(ResourceGroupName, WebsiteName, slotName, deleteEmptyServerFarmByDefault, deleteMetricsByDefault, deleteSlotsByDefault)); + } + + } +} + + + diff --git a/src/ResourceManager/Websites/Commands.Websites/Cmdlets/RestartAzureWebsite.cs b/src/ResourceManager/Websites/Commands.Websites/Cmdlets/RestartAzureWebsite.cs new file mode 100644 index 000000000000..161b1fa71481 --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/Cmdlets/RestartAzureWebsite.cs @@ -0,0 +1,60 @@ + +// ---------------------------------------------------------------------------------- +// +// 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 System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Management.Automation; +using Microsoft.Azure.Management.WebSites.Models; +using Microsoft.WindowsAzure; +using Microsoft.WindowsAzure.Commands.Utilities.CloudService; +using Microsoft.Azure.Commands.Websites; +using Microsoft.Azure.Management.WebSites; +using System.Net.Http; +using System.Threading; +using Microsoft.IdentityModel.Clients.ActiveDirectory; +using System.Net; +using Microsoft.Azure; +using Microsoft.WindowsAzure.Commands.Utilities.Common; +using Microsoft.Azure.Commands.Websites.Utilities; + + +namespace Microsoft.Azure.Commands.Websites.Cmdlets +{ + /// + /// this commandlet will let you restart an Azure Website + /// + [Cmdlet(VerbsLifecycle.Restart, "AzureWebsite")] + public class RestartAzureWebsiteCmdlet : WebsiteBaseCmdlet + { + + [Parameter(Position = 2, Mandatory = false, HelpMessage = "The name of the website slot.")] + [ValidateNotNullOrEmptyAttribute] + public string SlotName { get; set; } + + public override void ExecuteCmdlet() + { + WriteObject(WebsitesClient.RestartWebsite(ResourceGroupName, WebsiteName, SlotName)); + } + + } +} + + + + diff --git a/src/ResourceManager/Websites/Commands.Websites/Cmdlets/StartAzureWebsite.cs b/src/ResourceManager/Websites/Commands.Websites/Cmdlets/StartAzureWebsite.cs new file mode 100644 index 000000000000..21ea1b375ef4 --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/Cmdlets/StartAzureWebsite.cs @@ -0,0 +1,60 @@ + +// ---------------------------------------------------------------------------------- +// +// 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 System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Management.Automation; +using Microsoft.Azure.Management.WebSites.Models; +using Microsoft.WindowsAzure; +using Microsoft.WindowsAzure.Commands.Utilities.CloudService; +using Microsoft.Azure.Commands.Websites; +using Microsoft.Azure.Management.WebSites; +using System.Net.Http; +using System.Threading; +using Microsoft.IdentityModel.Clients.ActiveDirectory; +using System.Net; +using Microsoft.Azure; +using Microsoft.WindowsAzure.Commands.Utilities.Common; +using Microsoft.Azure.Commands.Websites.Utilities; + + +namespace Microsoft.Azure.Commands.Websites.Cmdlets +{ + /// + /// this commandlet will let you Start an Azure Website + /// + [Cmdlet(VerbsLifecycle.Start, "AzureWebsite")] + public class StartAzureWebsiteCmdlet : WebsiteBaseCmdlet + { + + [Parameter(Position = 2, Mandatory = false, HelpMessage = "The name of the website slot.")] + [ValidateNotNullOrEmptyAttribute] + public string SlotName { get; set; } + + public override void ExecuteCmdlet() + { + WriteObject(WebsitesClient.StartWebsite(ResourceGroupName, WebsiteName, SlotName)); + + } + + } +} + + + diff --git a/src/ResourceManager/Websites/Commands.Websites/Cmdlets/StopAzureWebsite.cs b/src/ResourceManager/Websites/Commands.Websites/Cmdlets/StopAzureWebsite.cs new file mode 100644 index 000000000000..e484123f6b32 --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/Cmdlets/StopAzureWebsite.cs @@ -0,0 +1,59 @@ + +// ---------------------------------------------------------------------------------- +// +// 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 System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Management.Automation; +using Microsoft.Azure.Management.WebSites.Models; +using Microsoft.WindowsAzure; +using Microsoft.WindowsAzure.Commands.Utilities.CloudService; +using Microsoft.Azure.Commands.Websites; +using Microsoft.Azure.Management.WebSites; +using System.Net.Http; +using System.Threading; +using Microsoft.IdentityModel.Clients.ActiveDirectory; +using System.Net; +using Microsoft.Azure; +using Microsoft.WindowsAzure.Commands.Utilities.Common; +using Microsoft.Azure.Commands.Websites.Utilities; + + +namespace Microsoft.Azure.Commands.Websites.Cmdlets +{ + /// + /// this commandlet will let you stop an Azure Website + /// + [Cmdlet(VerbsLifecycle.Stop, "AzureWebsite")] + public class StopAzureWebsiteCmdlet : WebsiteBaseCmdlet + { + + [Parameter(Position = 2, Mandatory = false, HelpMessage = "The name of the website slot.")] + [ValidateNotNullOrEmptyAttribute] + public string SlotName { get; set; } + + public override void ExecuteCmdlet() + { + WriteObject(WebsitesClient.StopWebsite(ResourceGroupName, WebsiteName, SlotName)); + } + + } +} + + + diff --git a/src/ResourceManager/Websites/Commands.Websites/Commands.Websites.csproj b/src/ResourceManager/Websites/Commands.Websites/Commands.Websites.csproj new file mode 100644 index 000000000000..d7c5c4744487 --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/Commands.Websites.csproj @@ -0,0 +1,177 @@ + + + + + Debug + AnyCPU + {80A92297-7C92-456B-8EE7-9FB6CE30149D} + Library + Properties + Microsoft.Azure.Commands.Websites + Microsoft.Azure.Commands.Websites + v4.5 + 512 + + ..\..\..\ + true + /assemblyCompareMode:StrongNameIgnoringVersion + + + true + full + false + ..\..\..\Package\Debug\ResourceManager\AzureResourceManager\Websites\ + DEBUG;TRACE + prompt + 4 + true + true + false + + + ..\..\..\Package\Release\ResourceManager\AzureResourceManager\Resources + TRACE;SIGN + true + pdbonly + AnyCPU + bin\Release\Microsoft.Azure.Commands.Resources.dll.CodeAnalysisLog.xml + true + GlobalSuppressions.cs + prompt + MinimumRecommendedRules.ruleset + ;$(ProgramFiles)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\Rule Sets + ;$(ProgramFiles)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\Rules + true + true + MSSharedLibKey.snk + true + false + + + + ..\..\..\packages\Hyak.Common.1.0.1\lib\portable-net403+win+wpa81\Hyak.Common.dll + + + ..\..\..\packages\Microsoft.Azure.Common.2.0.1\lib\net45\Microsoft.Azure.Common.dll + + + False + ..\..\..\packages\Microsoft.Azure.Common.Extensions.0.13.0-preview\lib\net45\Microsoft.Azure.Common.Extensions.dll + + + ..\..\..\packages\Microsoft.Azure.Common.2.0.1\lib\net45\Microsoft.Azure.Common.NetFramework.dll + + + False + ..\..\..\packages\Microsoft.Azure.Gallery.2.6.0-preview\lib\net40\Microsoft.Azure.Gallery.dll + + + False + ..\..\..\packages\Microsoft.Azure.Graph.RBAC.1.6.0-preview\lib\net40\Microsoft.Azure.Graph.RBAC.dll + + + False + ..\..\..\packages\Microsoft.Azure.Management.Authorization.0.16.0-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll + + + ..\..\..\packages\Microsoft.Azure.Management.WebSites.0.16.0-prerelease\lib\net40\Microsoft.Azure.Management.WebSites.dll + + + False + ..\..\..\packages\Microsoft.Azure.Management.Resources.2.12.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll + + + False + ..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.11.10918.1222\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll + + + False + ..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.11.10918.1222\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll + + + False + ..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll + + + False + ..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + + + False + ..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + + + False + ..\..\..\packages\Microsoft.WindowsAzure.Management.4.0.0\lib\net40\Microsoft.WindowsAzure.Management.dll + + + + + + + False + ..\..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll + + + False + ..\..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll + + + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + + {5ee72c53-1720-4309-b54b-5fb79703195f} + Commands.Common + + + {4900ec4e-8deb-4412-9108-0bc52f81d457} + Commands.Utilities + + + + + Designer + Always + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + + + + + + + + + \ No newline at end of file diff --git a/src/ResourceManager/Websites/Commands.Websites/MSSharedLibKey.snk b/src/ResourceManager/Websites/Commands.Websites/MSSharedLibKey.snk new file mode 100644 index 000000000000..695f1b38774e Binary files /dev/null and b/src/ResourceManager/Websites/Commands.Websites/MSSharedLibKey.snk differ diff --git a/src/ResourceManager/Websites/Commands.Websites/Microsoft.Azure.Commands.Websites.dll-Help.psd1 b/src/ResourceManager/Websites/Commands.Websites/Microsoft.Azure.Commands.Websites.dll-Help.psd1 new file mode 100644 index 000000000000..49a0bd881e67 --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/Microsoft.Azure.Commands.Websites.dll-Help.psd1 @@ -0,0 +1,88 @@ +# +# Module manifest for module 'Microsoft.Azure.Commands.Resources' +# +# Generated by: Microsoft Corporation +# +# Generated on: 4/01/2014 +# + +@{ + +# Version number of this module. +ModuleVersion = '0.8.8' + +# ID used to uniquely identify this module +GUID = '81d522a4-6e5d-4105-8f58-376204c47458' + +# Author of this module +Author = 'Microsoft Corporation' + +# Company or vendor of this module +CompanyName = 'Microsoft Corporation' + +# Copyright statement for this module +Copyright = '© Microsoft Corporation. All rights reserved.' + +# Description of the functionality provided by this module +Description = '' + +# Minimum version of the Windows PowerShell engine required by this module +PowerShellVersion = '3.0' + +# Name of the Windows PowerShell host required by this module +PowerShellHostName = '' + +# Minimum version of the Windows PowerShell host required by this module +PowerShellHostVersion = '' + +# Minimum version of the .NET Framework required by this module +DotNetFrameworkVersion = '4.0' + +# Minimum version of the common language runtime (CLR) required by this module +CLRVersion='4.0' + +# Processor architecture (None, X86, Amd64, IA64) required by this module +ProcessorArchitecture = 'None' + +# Modules that must be imported into the global environment prior to importing this module +RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module +ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in ModuleToProcess +NestedModules = @( + '..\..\..\Package\Debug\ResourceManager\AzureResourceManager\Resources\Microsoft.Azure.Commands.Websites.dll' +) + +# Functions to export from this module +FunctionsToExport = '*' + +# Cmdlets to export from this module +CmdletsToExport = '*' + +# Variables to export from this module +VariablesToExport = '*' + +# Aliases to export from this module +AliasesToExport = @() + +# List of all modules packaged with this module +ModuleList = @() + +# List of all files packaged with this module +FileList = @() + +# Private data to pass to the module specified in ModuleToProcess +PrivateData = '' + +} diff --git a/src/ResourceManager/Websites/Commands.Websites/Microsoft.Azure.Commands.Websites.dll-Help.xml b/src/ResourceManager/Websites/Commands.Websites/Microsoft.Azure.Commands.Websites.dll-Help.xml new file mode 100644 index 000000000000..6973d67d8afd --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/Microsoft.Azure.Commands.Websites.dll-Help.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/ResourceManager/Websites/Commands.Websites/Models.Websites/WebsiteBaseCmdlet.cs b/src/ResourceManager/Websites/Commands.Websites/Models.Websites/WebsiteBaseCmdlet.cs new file mode 100644 index 000000000000..f0889bd85b26 --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/Models.Websites/WebsiteBaseCmdlet.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 Microsoft.Azure.Commands.Websites.Models; +using System.Management.Automation; +using Microsoft.Azure.Commands.Websites.Models.Websites; + +namespace Microsoft.Azure.Commands.Websites +{ + public abstract class WebsiteBaseCmdlet : WebsitesBaseClient + { + [Parameter(Position = 0, Mandatory = true, HelpMessage = "The name of the resource group.")] + [ValidateNotNullOrEmptyAttribute] + public string ResourceGroupName { get; set; } + + [Parameter(Position = 1, Mandatory = true, HelpMessage = "The name of the website.")] + [ValidateNotNullOrEmptyAttribute] + public string WebsiteName { get; set; } + } +} + diff --git a/src/ResourceManager/Websites/Commands.Websites/Models.Websites/WebsitesBaseClient.cs b/src/ResourceManager/Websites/Commands.Websites/Models.Websites/WebsitesBaseClient.cs new file mode 100644 index 000000000000..87afdb1a6b9f --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/Models.Websites/WebsitesBaseClient.cs @@ -0,0 +1,43 @@ +// ---------------------------------------------------------------------------------- +// +// 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 System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.WindowsAzure.Commands.Utilities.Common; +using Microsoft.Azure.Commands.Websites.Utilities; + + +namespace Microsoft.Azure.Commands.Websites.Models.Websites +{ + public abstract class WebsitesBaseClient : AzurePSCmdlet + { + private WebsitesClient _websitesClient; + public WebsitesClient WebsitesClient + { + get + { + if (_websitesClient == null) + { + _websitesClient = new WebsitesClient(CurrentContext); + } + return _websitesClient; + } + set { _websitesClient = value; } + } + } +} diff --git a/src/ResourceManager/Websites/Commands.Websites/Properties/AssemblyInfo.cs b/src/ResourceManager/Websites/Commands.Websites/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..6a5df38250c2 --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/Properties/AssemblyInfo.cs @@ -0,0 +1,34 @@ +// ---------------------------------------------------------------------------------- +// +// 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 System; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Microsoft Azure Powershell - Azure Websites")] +[assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)] +[assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)] +[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)] + +[assembly: ComVisible(false)] +[assembly: CLSCompliant(false)] +[assembly: Guid("e386b843-f3f0-4db3-8664-37d16b860dde")] +[assembly: AssemblyVersion(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyVersion)] +[assembly: AssemblyFileVersion(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyFileVersion)] +#if SIGN +[assembly: InternalsVisibleTo("Microsoft.Azure.Commands.Resources.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] +#else +[assembly: InternalsVisibleTo("Microsoft.Azure.Commands.Websites.Test")] +#endif \ No newline at end of file diff --git a/src/ResourceManager/Websites/Commands.Websites/Properties/Resources.Designer.cs b/src/ResourceManager/Websites/Commands.Websites/Properties/Resources.Designer.cs new file mode 100644 index 000000000000..9691eb9e5472 --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/Properties/Resources.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34014 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.Azure.Commands.Websites.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Azure.Commands.Websites.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Are you sure you want to remove website '{0}'. + /// + internal static string RemovingWebsite { + get { + return ResourceManager.GetString("RemovingWebsite", resourceCulture); + } + } + } +} diff --git a/src/ResourceManager/Websites/Commands.Websites/Properties/Resources.resx b/src/ResourceManager/Websites/Commands.Websites/Properties/Resources.resx new file mode 100644 index 000000000000..3de28f1283fa --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/Properties/Resources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Are you sure you want to remove website '{0}' + + \ No newline at end of file diff --git a/src/ResourceManager/Websites/Commands.Websites/Utilities/WebsitesClient.cs b/src/ResourceManager/Websites/Commands.Websites/Utilities/WebsitesClient.cs new file mode 100644 index 000000000000..e5f18a9d8d0d --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/Utilities/WebsitesClient.cs @@ -0,0 +1,90 @@ +// ---------------------------------------------------------------------------------- +// +// 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 System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.Serialization.Formatters; +using System.Threading; +using Microsoft.Azure.Management.Resources; +using Microsoft.Azure.Commands; +using Microsoft.Azure.Management.WebSites; +using System.Net; +using Hyak.Common; +using Microsoft.Azure.Common.Extensions.Models; +using Microsoft.Azure.Common.Extensions; +using Microsoft.Azure.Management.WebSites.Models; + +namespace Microsoft.Azure.Commands.Websites.Utilities +{ + public class WebsitesClient + { + public WebsitesClient(AzureContext context) + { + this.WrappedWebsitesClient = AzureSession.ClientFactory.CreateClient(context, AzureEnvironment.Endpoint.ResourceManager); + + } + public WebSiteManagementClient WrappedWebsitesClient + { + get; + private set; + } + + + public WebSite CreateWebsite(string resourceGroupName, string webSiteName, string slotName, string location, string webHostingPlan) + { + var createdWebSite = WrappedWebsitesClient.WebSites.CreateOrUpdate( + resourceGroupName, webSiteName, slotName, + new WebSiteCreateOrUpdateParameters + { + WebSite = new WebSiteBase + { + Name = webSiteName, + Location = location, + Properties = new WebSiteBaseProperties(webHostingPlan) + } + }); + + return createdWebSite.WebSite; + } + + public System.Net.HttpStatusCode StartWebsite(string resourceGroupName, string webSiteName, string slotName) + { + var startedWebsite = WrappedWebsitesClient.WebSites.Start(resourceGroupName, webSiteName, slotName); + return startedWebsite.StatusCode; + } + public System.Net.HttpStatusCode StopWebsite(string resourceGroupName, string webSiteName, string slotName) + { + var stoppedWebsite = WrappedWebsitesClient.WebSites.Stop(resourceGroupName, webSiteName, slotName); + return stoppedWebsite.StatusCode; + } + public System.Net.HttpStatusCode RestartWebsite(string resourceGroupName, string webSiteName, string slotName) + { + var restartedWebsite = WrappedWebsitesClient.WebSites.Restart(resourceGroupName, webSiteName, slotName); + return restartedWebsite.StatusCode; + } + + public System.Net.HttpStatusCode RemoveWebsite(string resourceGroupName, string webSiteName, string slotName, bool deleteEmptyServerFarmBydefault, bool deleteMetricsBydefault, bool deleteSlotsBydefault) + { + WebSiteDeleteParameters webSiteDelParams = new WebSiteDeleteParameters(deleteEmptyServerFarmBydefault, deleteMetricsBydefault, deleteSlotsBydefault); + + var removedWebsite = WrappedWebsitesClient.WebSites.Delete(resourceGroupName, webSiteName, slotName, webSiteDelParams); + return removedWebsite.StatusCode; + } + + } +} diff --git a/src/ResourceManager/Websites/Commands.Websites/packages.config b/src/ResourceManager/Websites/Commands.Websites/packages.config new file mode 100644 index 000000000000..cf7eac4d7e1d --- /dev/null +++ b/src/ResourceManager/Websites/Commands.Websites/packages.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file