-
Notifications
You must be signed in to change notification settings - Fork 4.1k
[Storage] Add StaticWebSite Dataplane Support #6518
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| // ---------------------------------------------------------------------------------- | ||
| // | ||
| // 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. | ||
| // ---------------------------------------------------------------------------------- | ||
|
|
||
| namespace Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet | ||
| { | ||
| using Microsoft.WindowsAzure.Commands.Storage.Model.ResourceModel; | ||
| using Microsoft.WindowsAzure.Storage.Shared.Protocol; | ||
| using System; | ||
| using System.Management.Automation; | ||
| using System.Security.Permissions; | ||
|
|
||
| /// <summary> | ||
| /// Disable azure storage service StaticWebsite, currently only available on Blob service | ||
| /// </summary> | ||
| [Cmdlet(VerbsLifecycle.Disable, StorageNouns.ServiceStaticWebsite, SupportsShouldProcess = true), | ||
| OutputType(typeof(PSStaticWebsiteProperties))] | ||
| public class DisableAzureStorageServiceStaticWebsiteCommand : StorageCloudBlobCmdletBase | ||
| { | ||
| [Parameter(Mandatory = false)] | ||
| public SwitchParameter PassThru { get; set; } | ||
|
|
||
| // Overwrite the useless parameter | ||
|
||
| public override int? ServerTimeoutPerRequest { get; set; } | ||
| public override int? ClientTimeoutPerRequest { get; set; } | ||
| public override int? ConcurrentTaskCount { get; set; } | ||
|
|
||
| public DisableAzureStorageServiceStaticWebsiteCommand() | ||
| { | ||
| EnableMultiThread = false; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Update the specified StaticWebsite Properties according to the input | ||
| /// </summary> | ||
| /// <param name="policy">StaticWebsite Properties</param> | ||
| internal void DisableStaticWebsiteProperties(ServiceProperties serviceProperties) | ||
| { | ||
| if (serviceProperties.StaticWebsite == null) | ||
| { | ||
| serviceProperties.StaticWebsite = new StaticWebsiteProperties(); | ||
| } | ||
|
|
||
| serviceProperties.StaticWebsite.Enabled = false; | ||
| serviceProperties.StaticWebsite.IndexDocument = null; | ||
| serviceProperties.StaticWebsite.ErrorDocument404Path = null; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Execute command | ||
| /// </summary> | ||
| [PermissionSet(SecurityAction.Demand, Name = "FullTrust")] | ||
| public override void ExecuteCmdlet() | ||
| { | ||
| StorageServiceType serviceType = StorageServiceType.Blob; | ||
|
|
||
| if (ShouldProcess(serviceType.ToString(), "Disable Static Website")) | ||
| { | ||
| ServiceProperties serviceProperties = Channel.GetStorageServiceProperties(serviceType, GetRequestOptions(serviceType), OperationContext); | ||
|
|
||
| DisableStaticWebsiteProperties(serviceProperties); | ||
|
|
||
| Channel.SetStorageServiceProperties(serviceType, serviceProperties, | ||
| GetRequestOptions(serviceType), OperationContext); | ||
|
|
||
| if (PassThru) | ||
| { | ||
| WriteObject(PSStaticWebsiteProperties.ParsePSStaticWebsiteProperties(serviceProperties.StaticWebsite)); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assuming this will be undone once the new SDK is released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will update all the reference when the XSCL is release. Currently remove the “PublicKeyToken” only to make the private XSCL work.