< Back

Set-AzureStorageCORSRule

Tue Jan 29, 2019 9:28 pm

NAME Set-AzureStorageCORSRule



SYNOPSIS

Sets the CORS rules for a type of Storage service.





SYNTAX

Set-AzureStorageCORSRule [-ServiceType] {Blob | Table | Queue | File} [-ClientTimeoutPerRequest <Int32>] [-ConcurrentTaskCount <Int32>] [-Context

<IStorageContext>] -CorsRules <PSCorsRule[]> [-PassThru] [-ServerTimeoutPerRequest <Int32>] [<CommonParameters>]





DESCRIPTION

The Set-AzureStorageCORSRule cmdlet sets the Cross-Origin Resource Sharing (CORS) rules for a type of Azure Storage service. The types of storage

services for this cmdlet are Blob, Table, Queue, and File. This cmdlet overwrites the existing rules. To see the current rules, use the

Get-AzureStorageCORSRule cmdlet.





PARAMETERS

-ClientTimeoutPerRequest <Int32>

Specifies the client-side time-out interval, in seconds, for one service request. If the previous call fails in the specified interval, this

cmdlet retries the request. If this cmdlet does not receive a successful response before the interval elapses, this cmdlet returns an error.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-ConcurrentTaskCount <Int32>

Specifies the maximum concurrent network calls. You can use this parameter to limit the concurrency to throttle local CPU and bandwidth usage

by specifying the maximum number of concurrent network calls. The specified value is an absolute count and is not multiplied by the core

count. This parameter can help reduce network connection problems in low bandwidth environments, such as 100 kilobits per second. The default

value is 10.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Context <IStorageContext>

Specifies an Azure Storage context. To obtain a context, use the New-AzureStorageContext cmdlet.



Required? false

Position? named

Default value None

Accept pipeline input? True (ByPropertyName, ByValue)

Accept wildcard characters? false



-CorsRules <PSCorsRule[]>

Specifies an array of CORS rules. You can retrieve the existing rules using the Get-AzureStorageCORSRule cmdlet.



Required? true

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-PassThru [<SwitchParameter>]

Indicates that this cmdlet returns a Boolean that reflects the success of the operation. By default, this cmdlet does not return a value.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-ServerTimeoutPerRequest <Int32>

Specifies the length of the time-out period for the server part of a request.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-ServiceType <StorageServiceType>

Specifies the Azure Storage service type for which this cmdlet assigns rules. The acceptable values for this parameter are:



- Blob



- Table



- Queue



- File



Required? true

Position? 0

Default value None

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

IStorageContext

Parameter 'Context' accepts value of type 'IStorageContext' from the pipeline





OUTPUTS

Microsoft.WindowsAzure.Commands.Storage.Model.ResourceModel.PSCorsRule







NOTES









Example 1: Assign CORS rules to the blob service



PS C:\\>$CorsRules = (@{

AllowedHeaders=@("x-ms-blob-content-type","x-ms-blob-content-disposition");

AllowedOrigins=@("*");

MaxAgeInSeconds=30;

AllowedMethods=@("Get","Connect")},

@{

AllowedOrigins=@("http://www.fabrikam.com","http://www.contoso.com");

ExposedHeaders=@("x-ms-meta-data*","x-ms-meta-customheader");

AllowedHeaders=@("x-ms-meta-target*","x-ms-meta-customheader");

MaxAgeInSeconds=30;

AllowedMethods=@("Put")})

PS C:\\> Set-AzureStorageCORSRule -ServiceType Blob -CorsRules $CorsRules



The first command assigns an array of rules to the $CorsRules variable. This command uses standard extends over several lines in this code block.



The second command assigns the rules in $CorsRules to the Blob service type.





Example 2: Change properties of a CORS rule for blob service



PS C:\\>$CorsRules = Get-AzureStorageCORSRule -ServiceType Blob

PS C:\\> $CorsRules[0].AllowedHeaders = @("x-ms-blob-content-type", "x-ms-blob-content-disposition")

PS C:\\> $CorsRules[0].AllowedMethods = @("Get", "Connect", "Merge")

PS C:\\> Set-AzureStorageCORSRule -ServiceType Blob -CorsRules $CorsRules



The first command gets the current CORS rules for the Blob type by using the Get-AzureStorageCORSRule cmdlet. The command stores the rules in the

$CorsRules array variable.



The second and third commands modify the first rule in $CorsRules.



The final command assigns the rules in $CorsRules to the Blob service type. The revised rules overwrite the current CORS rules.







RELATED LINKS

Online Version: https://docs.microsoft.com/en-us/powers ... gecorsrule

Get-AzureStorageCORSRule

New-AzureStorageContext

Remove-AzureStorageCORSRule