Skip to content

Initial commit for the Websites commandlets for ARM #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/AzurePowershell.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -161,7 +161,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StreamAnalytics.Te
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Insights", "ResourceManager\Insights\Commands.Insights\Commands.Insights.csproj", "{DEA446A1-84E2-46CC-B780-EB4AFDE2460E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Insights.Test", "ResourceManager\Insights\Commands.Insights.Test\Commands.Insights.Test.csproj", "{469F20E0-9D40-41AD-94C3-B47AD15A4C00}"
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
Expand Down Expand Up @@ -393,10 +393,10 @@ Global
{DEA446A1-84E2-46CC-B780-EB4AFDE2460E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEA446A1-84E2-46CC-B780-EB4AFDE2460E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEA446A1-84E2-46CC-B780-EB4AFDE2460E}.Release|Any CPU.Build.0 = Release|Any CPU
{469F20E0-9D40-41AD-94C3-B47AD15A4C00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{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
Expand Down Expand Up @@ -429,6 +429,5 @@ Global
{A415F75B-EB6A-49A6-934E-5BA71B83D6EB} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
{0FA676D5-1349-4086-B33F-65EC2CB7DA41} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
{7E6683BE-ECFF-4709-89EB-1325E9E70512} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
{469F20E0-9D40-41AD-94C3-B47AD15A4C00} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ FormatsToProcess = @(
'.\Batch\Microsoft.Azure.Commands.Batch.format.ps1xml',
'.\KeyVault\Microsoft.Azure.Commands.KeyVault.format.ps1xml',
'.\StreamAnalytics\Microsoft.Azure.Commands.StreamAnalytics.format.ps1xml'
'.\Websites\Microsoft.Azure.Commands.Websites.format.ps1xml'
)

# Modules to import as nested modules of the module specified in ModuleToProcess
Expand All @@ -80,6 +81,7 @@ NestedModules = @(
'.\KeyVault\Microsoft.Azure.Commands.KeyVault.dll',
'.\StreamAnalytics\Microsoft.Azure.Commands.StreamAnalytics.dll',
'.\Insights\Microsoft.Azure.Commands.Insights.dll'
'.\Websites\Microsoft.Azure.Commands.Websites.dll'
)

# Functions to export from this module
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#
# 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.13'

# 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 = @(
'.\Resources\Microsoft.Azure.Commands.Resources.format.ps1xml',
'.\Tags\Microsoft.Azure.Commands.Tags.format.ps1xml',
'.\Resources\Microsoft.WindowsAzure.Commands.Profile.format.ps1xml',
'.\DataFactories\Microsoft.Azure.Commands.DataFactories.format.ps1xml',
'.\RedisCache\Microsoft.Azure.Commands.RedisCache.format.ps1xml',
'.\Batch\Microsoft.Azure.Commands.Batch.format.ps1xml',
'.\KeyVault\Microsoft.Azure.Commands.KeyVault.format.ps1xml'
'.\StreamAnalytics\Microsoft.Azure.Commands.StreamAnalytics.format.ps1xml'
'.\Websites\Microsoft.Azure.Commands.Websites.format.ps1xml'
)

# Modules to import as nested modules of the module specified in ModuleToProcess
NestedModules = @(
'.\Resources\Microsoft.Azure.Commands.Resources.dll',
'.\Resources\Microsoft.WindowsAzure.Commands.Profile.dll',
'.\Tags\Microsoft.Azure.Commands.Tags.dll',
'.\Sql\Microsoft.Azure.Commands.Sql.dll',
'.\DataFactories\Microsoft.Azure.Commands.DataFactories.dll',
'.\RedisCache\Microsoft.Azure.Commands.RedisCache.dll',
'.\Batch\Microsoft.Azure.Commands.Batch.dll',
'.\KeyVault\Microsoft.Azure.Commands.KeyVault.dll'
'.\StreamAnalytics\Microsoft.Azure.Commands.StreamAnalytics.dll'
'.\Websites\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 = ''

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// ----------------------------------------------------------------------------------
//
// 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
{
/// <summary>
/// this commandlet will let you create a new backuppolicy with schedules
/// </summary>
[Cmdlet(VerbsCommon.New, "AzureWebsite")]
public class NewAzureWebsiteCmdlet : AzurePSCmdlet
{
[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; }

[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; }

private WebsitesClient _websitesClient;
private WebsitesClient WebsitesClient
{
get
{
if (_websitesClient == null)
{
_websitesClient = new WebsitesClient(CurrentContext);
}
return _websitesClient;
}
}



public override void ExecuteCmdlet()
{
WriteObject(WebsitesClient.CreateWebsite(ResourceGroupName, WebsiteName, SlotName, Location, WebHostingPlan));

}

}
}



Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@

// ----------------------------------------------------------------------------------
//
// 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
{
/// <summary>
/// this commandlet will let you create a new backuppolicy with schedules
/// </summary>
[Cmdlet(VerbsCommon.Remove, "AzureWebsite")]
public class RemoveAzureWebsiteCmdlet : AzurePSCmdlet
{

private bool deleteSlotsBydefault = false;
private bool deleteEmptyServerFarmBydefault = false;
private bool deleteMetricsBydefault = false;

[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; }

[Parameter(Position = 2, Mandatory = false, HelpMessage = "The name of the website slot.")]
[ValidateNotNullOrEmptyAttribute]
public string SlotName { get; set; }

[Parameter(Position = 3, Mandatory = true, HelpMessage = "Delete all website slots?")]
[ValidateNotNullOrEmptyAttribute]
public bool DeleteAllSlots
{
get { return this.deleteSlotsBydefault; }
set { this.deleteSlotsBydefault = value; }
}

[Parameter(Position = 4, Mandatory = true, HelpMessage = "Delete empty website server farm?")]
[ValidateNotNullOrEmptyAttribute]
public bool DeleteEmptyServerFarm
{
get { return this.deleteEmptyServerFarmBydefault; }
set { this.deleteEmptyServerFarmBydefault = value; }
}

[Parameter(Position = 5, Mandatory = true, HelpMessage = "Delete website metrics?")]
[ValidateNotNullOrEmptyAttribute]
public bool DeleteMetrics
{
get { return this.deleteMetricsBydefault; }
set { this.deleteMetricsBydefault = value; }
}




private WebsitesClient _websitesClient;
private WebsitesClient WebsitesClient
{
get
{
if (_websitesClient == null)
{
_websitesClient = new WebsitesClient(CurrentContext);
}
return _websitesClient;
}
}



public override void ExecuteCmdlet()
{
WriteObject(WebsitesClient.RemoveWebsite(ResourceGroupName, WebsiteName, SlotName, deleteEmptyServerFarmBydefault, deleteMetricsBydefault, deleteSlotsBydefault));
}

}
}



Loading