Skip to content

Changed the parameter WebsiteName to Name to use in piping. Added publis... #268

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

Merged
merged 1 commit into from
Mar 18, 2015
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ function Test-CreatesNewSimpleWebsite
New-AzureWebHostingPlan -ResourceGroupName $rgname -WebHostingPlanName $whpName -location $location

# Test
$actual = New-AzureWebsite -ResourceGroupName $rgname -WebsiteName $wname -Location $location -WebHostingPlan $whpName
$result = Get-AzureWebsite -ResourceGroupName $rgname -WebsiteName $wname
$actual = New-AzureWebsite -ResourceGroupName $rgname -Name $wname -Location $location -WebHostingPlan $whpName
$result = Get-AzureWebsite -ResourceGroupName $rgname -Name $wname

# Assert
Assert-AreEqual $wname $result.Name
Expand All @@ -42,7 +42,7 @@ function Test-CreatesNewSimpleWebsite
finally
{
# Cleanup
Remove-AzureWebsite -ResourceGroupName $rgname -WebsiteName $wname -Force
Remove-AzureWebsite -ResourceGroupName $rgname -Name $wname -Force
Remove-AzureWebHostingPlan -ResourceGroupName $rgname -WebHostingPlanName $whpName -Force
Remove-AzureResourceGroup -Name $rgname -Force
}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,11 @@ namespace Microsoft.Azure.Commands.Websites.Cmdlets
/// this commandlet will let you create a new Azure Websites using ARM APIs
/// </summary>
[Cmdlet(VerbsCommon.Get, "AzureWebsite")]
public class GetAzureWebsiteCmdlet : WebsiteBaseCmdlet
public class GetAzureWebsiteCmdlet : WebsiteBaseSlotCmdlet
{

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

public override void ExecuteCmdlet()
{
WriteObject(WebsitesClient.GetWebsite(ResourceGroupName, WebsiteName, SlotName));
WriteObject(WebsitesClient.GetWebsite(ResourceGroupName, Name, SlotName));

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

// ----------------------------------------------------------------------------------
//
// 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 get the publishing creds of the given Azure Websites using ARM APIs
/// </summary>
[Cmdlet(VerbsCommon.Get, "AzureWebsitePublishingProfile")]
public class GetAzureWebsitePublishingProfileCmdlet : WebsiteBaseSlotCmdlet
{
public override void ExecuteCmdlet()
{
WriteObject(WebsitesClient.GetWebsitePublishingProfile(ResourceGroupName, Name, SlotName));

}

}
}



Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class NewAzureWebsiteCmdlet : WebsiteBaseCmdlet

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

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Microsoft.Azure.Commands.Websites.Cmdlets
/// this commandlet will let you delete an Azure website
/// </summary>
[Cmdlet(VerbsCommon.Remove, "AzureWebsite")]
public class RemoveAzureWebsiteCmdlet : WebsiteBaseCmdlet
public class RemoveAzureWebsiteCmdlet : WebsiteBaseNotMandatoryCmdlet
{

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

public override void ExecuteCmdlet()
{
// Currently we delete all slots.
string slotName = null;

ConfirmAction(
Force.IsPresent,
string.Format(Resources.RemoveWebsiteWarning, WebsiteName),
string.Format(Resources.RemoveWebsiteWarning, Name),
Resources.RemoveWebsiteMessage,
WebsiteName,
() => WebsitesClient.RemoveWebsite(ResourceGroupName, WebsiteName, slotName, deleteEmptyServerFarmByDefault, deleteMetricsByDefault, deleteSlotsByDefault));
Name,
() => WebsitesClient.RemoveWebsite(ResourceGroupName, Name, slotName, deleteEmptyServerFarmByDefault, deleteMetricsByDefault, deleteSlotsByDefault));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class RestartAzureWebsiteCmdlet : WebsiteBaseCmdlet

public override void ExecuteCmdlet()
{
WriteObject(WebsitesClient.RestartWebsite(ResourceGroupName, WebsiteName, SlotName));
WriteObject(WebsitesClient.RestartWebsite(ResourceGroupName, Name, SlotName));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class StartAzureWebsiteCmdlet : WebsiteBaseCmdlet

public override void ExecuteCmdlet()
{
WriteObject(WebsitesClient.StartWebsite(ResourceGroupName, WebsiteName, SlotName));
WriteObject(WebsitesClient.StartWebsite(ResourceGroupName, Name, SlotName));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class StopAzureWebsiteCmdlet : WebsiteBaseCmdlet

public override void ExecuteCmdlet()
{
WriteObject(WebsitesClient.StopWebsite(ResourceGroupName, WebsiteName, SlotName));
WriteObject(WebsitesClient.StopWebsite(ResourceGroupName, Name, SlotName));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class NewAzureWebHostingPlanCmdlet : WebHostingPlanBaseCmdlet
[ValidateNotNullOrEmptyAttribute]
public int NumberofWorkers { get; set; }

[Parameter(Position = 5, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The size of he workers: eg Small, Medium, Large")]
[Parameter(Position = 5, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The size of the workers: eg Small, Medium, Large")]
[ValidateNotNullOrEmptyAttribute]
[ValidateSet("Small", "Medium", "Large", IgnoreCase = true)]
public string WorkerSize { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
</ItemGroup>
<ItemGroup>
<Compile Include="Cmdlets\GetAzureWebsitePublishingProfile .cs" />
<Compile Include="Cmdlets\GetAzureWebsite.cs" />
<Compile Include="Cmdlets\RemoveAzureWebsite.cs" />
<Compile Include="Cmdlets\NewAzureWebsites.cs" />
Expand All @@ -137,6 +138,8 @@
<Compile Include="Cmdlets\WebHostingPlan\NewAzureWebHostingPlan.cs" />
<Compile Include="Cmdlets\WebHostingPlan\RemoveWebHostingPlan.cs" />
<Compile Include="Models.Websites\WebHostingPlanBaseCmdlet.cs" />
<Compile Include="Models.Websites\WebsiteBaseNotMandatoryCmdlet.cs" />
<Compile Include="Models.Websites\WebsiteBaseSlotCmdlet.cs" />
<Compile Include="Models.Websites\WebsiteBaseCmdlet.cs" />
<Compile Include="Models.Websites\WebsitesBaseClient.cs" />
<Compile Include="Utilities\WebsitesClient.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class WebsiteBaseCmdlet : WebsitesBaseClient

[Parameter(Position = 1, Mandatory = true, HelpMessage = "The name of the website.")]
[ValidateNotNullOrEmptyAttribute]
public string WebsiteName { get; set; }
public string Name { get; set; }
}
}

Original file line number Diff line number Diff line change
@@ -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 class WebsiteBaseNotMandatoryCmdlet : WebsitesBaseClient
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really related to this change but I think that WebsitesBaseClient should be renamed as it's misleading, it is actually a Cmdlet and not a Client (only holds a client).

{
[Parameter(Position = 0, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the resource group.")]
[ValidateNotNullOrEmptyAttribute]
public string ResourceGroupName { get; set; }

[Parameter(Position = 1, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the website.")]
[ValidateNotNullOrEmptyAttribute]
public string Name { get; set; }
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// ----------------------------------------------------------------------------------
//
// 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 class WebsiteBaseSlotCmdlet : WebsitesBaseClient
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should derive from WebsiteBaseCmdlet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this with other changes in the pipe will update in next pull

{
[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 Name { get; set; }

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

Original file line number Diff line number Diff line change
Expand Up @@ -92,58 +92,79 @@ public System.Net.HttpStatusCode RemoveWebsite(string resourceGroupName, string
public WebSite GetWebsite(string resourceGroupName, string webSiteName, string slotName)
{
WebSiteGetParameters webSiteGetParams = new WebSiteGetParameters();

var getWebsite = WrappedWebsitesClient.WebSites.Get(resourceGroupName, webSiteName, slotName, webSiteGetParams);
try
{
var getAppSettings = WrappedWebsitesClient.WebSites.GetAppSettings(resourceGroupName, webSiteName, slotName);
//Add websiteApp Settings to the Website object as the Get call will not return them.
foreach (var appSettingVal in getAppSettings.Resource.Properties.ToList())
{
if (!getWebsite.WebSite.Properties.Properties.AppSettings.Keys.Contains(appSettingVal.Name))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need this check?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also if you do its missing {}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getWebsite.WebSite.Properties.Properties.AppSettings.Add[appSettingVal.Name] = appSettingVal.Value

getWebsite.WebSite.Properties.Properties.AppSettings.Add(appSettingVal.Name, appSettingVal.Value);
}
}
catch
{
//ignore if this call fails as it will for reader RBAC
}
//Add ConnectionStrings Settings to the Website object as the Get call will not return them.

try
{
var getConnectionStringsSettings = WrappedWebsitesClient.WebSites.GetConnectionStrings(resourceGroupName, webSiteName, slotName);
//TODO: Add ConnectionStrings Settings to the Website object as the Get call will not return them.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should either use getConnectionStringsSettings or remove this code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its in TODO: waiting on a modified website object will update tomorrow.



}
catch
{
//ignore if this call fails as it will for reader RBAC
}

return getWebsite.WebSite;
}

public WebSiteGetPublishProfileResponse GetWebsitePublishingProfile(string resourceGroupName, string webSiteName, string slotName)
{
var pubCreds = WrappedWebsitesClient.WebSites.GetPublishProfile(resourceGroupName, webSiteName, slotName);
return pubCreds;
}

public WebHostingPlanCreateOrUpdateResponse CreateWebHostingPlan(string resourceGroupName, string whpName, string location, string adminSiteName, int numberOfWorkers, SkuOptions sku, WorkerSizeOptions workerSize)
{


WebHostingPlanProperties webHostingPlanProperties = new WebHostingPlanProperties();
webHostingPlanProperties.Sku = sku;
webHostingPlanProperties.AdminSiteName = adminSiteName;
webHostingPlanProperties.NumberOfWorkers = numberOfWorkers;
webHostingPlanProperties.WorkerSize = workerSize;

WebHostingPlan webHostingPlan = new WebHostingPlan();

WebHostingPlan webHostingPlan = new WebHostingPlan();
WebHostingPlanCreateOrUpdateParameters webHostingPlanCreateOrUpdateParameters = new WebHostingPlanCreateOrUpdateParameters(webHostingPlan);
webHostingPlanCreateOrUpdateParameters.WebHostingPlan.Location = location;
webHostingPlanCreateOrUpdateParameters.WebHostingPlan.Name = whpName;
webHostingPlanCreateOrUpdateParameters.WebHostingPlan.Properties = webHostingPlanProperties;

var createdWHP = WrappedWebsitesClient.WebHostingPlans.CreateOrUpdate(resourceGroupName, webHostingPlanCreateOrUpdateParameters);

//proper return type need to be discussed
return createdWHP;
}

public AzureOperationResponse RemoveWebHostingPlan(string resourceGroupName, string whpName)
{

var response = WrappedWebsitesClient.WebHostingPlans.Delete(resourceGroupName, whpName);

//proper return type need to be discussed
return response;
}

public WebHostingPlanGetResponse GetWebHostingPlan(string resourceGroupName, string whpName)
{

var response = WrappedWebsitesClient.WebHostingPlans.Get(resourceGroupName, whpName);

//proper return type need to be discussed
return response;
}

public WebHostingPlanListResponse ListWebHostingPlan(string resourceGroupName)
{

{
var response = WrappedWebsitesClient.WebHostingPlans.List(resourceGroupName);

//proper return type need to be discussed
return response;
}
Expand Down