external help file | Module Name | ms.assetid | online version | schema |
---|---|---|---|---|
Microsoft.WindowsAzure.Commands.Storage.dll-Help.xml |
Azure.Storage |
383402B2-6B7C-41AB-AFF9-36C86156B0A9 |
2.0.0 |
Creates an Azure Storage context.
New-AzureStorageContext [-StorageAccountName] <String> [-UseConnectedAccount] [-Protocol <String>]
[-Endpoint <String>] [<CommonParameters>]
New-AzureStorageContext [-StorageAccountName] <String> [-StorageAccountKey] <String> [-Protocol <String>]
[-Endpoint <String>] [<CommonParameters>]
New-AzureStorageContext [-StorageAccountName] <String> [-StorageAccountKey] <String> [-Protocol <String>]
-Environment <String> [<CommonParameters>]
New-AzureStorageContext [-StorageAccountName] <String> [-Anonymous] [-Protocol <String>] [-Endpoint <String>]
[<CommonParameters>]
New-AzureStorageContext [-StorageAccountName] <String> [-Anonymous] [-Protocol <String>] -Environment <String>
[<CommonParameters>]
New-AzureStorageContext [-StorageAccountName] <String> -SasToken <String> [-Protocol <String>]
[-Endpoint <String>] [<CommonParameters>]
New-AzureStorageContext [-StorageAccountName] <String> -SasToken <String> -Environment <String>
[<CommonParameters>]
New-AzureStorageContext [-StorageAccountName] <String> [-UseConnectedAccount] [-Protocol <String>]
-Environment <String> [<CommonParameters>]
New-AzureStorageContext -ConnectionString <String> [<CommonParameters>]
New-AzureStorageContext [-Local] [<CommonParameters>]
The New-AzureStorageContext cmdlet creates an Azure Storage context.
C:\PS>New-AzureStorageContext -StorageAccountName "ContosoGeneral" -StorageAccountKey "< Storage Key for ContosoGeneral ends with == >"
This command creates a context for the account named ContosoGeneral that uses the specified key.
C:\PS>New-AzureStorageContext -ConnectionString "DefaultEndpointsProtocol=https;AccountName=ContosoGeneral;AccountKey=< Storage Key for ContosoGeneral ends with == >;"
This command creates a context based on the specified connection string for the account ContosoGeneral.
C:\PS>New-AzureStorageContext -StorageAccountName "ContosoGeneral" -Anonymous -Protocol "http"
This command creates a context for anonymous use for the account named ContosoGeneral. The command specifies HTTP as a connection protocol.
C:\PS>New-AzureStorageContext -Local
This command creates a context by using the local development storage account. The command specifies the Local parameter.
C:\PS>New-AzureStorageContext -Local | Get-AzureStorageContainer
This command creates a context by using the local development storage account, and then passes the new context to the Get-AzureStorageContainer cmdlet by using the pipeline operator. The command gets the Azure Storage container for the local developer storage account.
C:\PS>$Context01 = New-AzureStorageContext -Local
PS C:\> $Context02 = New-AzureStorageContext -StorageAccountName "ContosoGeneral" -StorageAccountKey "< Storage Key for ContosoGeneral ends with == >"
PS C:\> ($Context01, $Context02) | Get-AzureStorageContainer
The first command creates a context by using the local development storage account, and then stores that context in the $Context01 variable. The second command creates a context for the account named ContosoGeneral that uses the specified key, and then stores that context in the $Context02 variable. The final command gets the containers for the contexts stored in $Context01 and $Context02 by using Get-AzureStorageContainer.
C:\PS>New-AzureStorageContext -StorageAccountName "ContosoGeneral" -StorageAccountKey "< Storage Key for ContosoGeneral ends with == >" -Endpoint "contosoaccount.core.windows.net"
This command creates an Azure Storage context that has the specified storage endpoint. The command creates the context for the account named ContosoGeneral that uses the specified key.
C:\PS>New-AzureStorageContext -StorageAccountName "ContosoGeneral" -StorageAccountKey "< Storage Key for ContosoGeneral ends with == >" -Environment "AzureChinaCloud"
This command creates an Azure storage context that has the specified Azure environment. The command creates the context for the account named ContosoGeneral that uses the specified key.
C:\PS>$SasToken = New-AzureStorageContainerSASToken -Name "ContosoMain" -Permission "rad"
PS C:\> $Context = New-AzureStorageContext -StorageAccountName "ContosoGeneral" -SasToken $SasToken
PS C:\> $Context | Get-AzureStorageBlob -Container "ContosoMain"
The first command generates an SAS token by using the New-AzureStorageContainerSASToken cmdlet for the container named ContosoMain, and then stores that token in the $SasToken variable. That token is for read, add, update, and delete permissions. The second command creates a context for the account named ContosoGeneral that uses the SAS token stored in $SasToken, and then stores that context in the $Context variable. The final command lists all the blobs associated with the container named ContosoMain by using the context stored in $Context.
C:\PS>Connect-AzureRmAccount
C:\PS> $Context = New-AzureStorageContext -StorageAccountName "myaccountname" -UseConnectedAccount
This command creates a context by using the OAuth Authentication.
Indicates that this cmdlet creates an Azure Storage context for anonymous logon.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: AnonymousAccount, AnonymousAccountEnvironment
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies a connection string for the Azure Storage context.
Type: System.String
Parameter Sets: ConnectionString
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies the endpoint for the Azure Storage context.
Type: System.String
Parameter Sets: OAuthAccount, AccountNameAndKey, AnonymousAccount, SasToken
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies the Azure environment.
The acceptable values for this parameter are: AzureCloud and AzureChinaCloud.
For more information, type Get-Help Get-AzureEnvironment
.
Type: System.String
Parameter Sets: AccountNameAndKeyEnvironment, AnonymousAccountEnvironment
Aliases: Name, EnvironmentName
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Type: System.String
Parameter Sets: SasTokenWithAzureEnvironment, OAuthAccountEnvironment
Aliases: Name, EnvironmentName
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Indicates that this cmdlet creates a context by using the local development storage account.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: LocalDevelopment
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Transfer Protocol (https/http).
Type: System.String
Parameter Sets: OAuthAccount, AccountNameAndKey, AccountNameAndKeyEnvironment, AnonymousAccount, AnonymousAccountEnvironment, SasToken, OAuthAccountEnvironment
Aliases:
Accepted values: Http, Https
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies a Shared Access Signature (SAS) token for the context.
Type: System.String
Parameter Sets: SasToken, SasTokenWithAzureEnvironment
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies an Azure Storage account key. This cmdlet creates a context for the key that this parameter specifies.
Type: System.String
Parameter Sets: AccountNameAndKey, AccountNameAndKeyEnvironment
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies an Azure Storage account name. This cmdlet creates a context for the account that this parameter specifies.
Type: System.String
Parameter Sets: OAuthAccount, AccountNameAndKey, AccountNameAndKeyEnvironment, AnonymousAccount, AnonymousAccountEnvironment, SasToken, SasTokenWithAzureEnvironment, OAuthAccountEnvironment
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Indicates that this cmdlet creates an Azure Storage context with OAuth Authentication. The cmdlet will use OAuth Authentication by default, when other anthentication not specified.
Type: SwitchParameter
Parameter Sets: OAuthAccount, OAuthAccountEnvironment
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Indicates that this cmdlet creates an Azure Storage context with OAuth Authentication. The cmdlet will use OAuth Authentication by default, when other anthentication not specified.
Type: SwitchParameter
Parameter Sets: OAuthAccount, OAuthAccountEnvironment
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).