Экспорт (0) Печать
Развернуть все
EN
Данное содержимое не доступно на вашем языке, используйте версию на английском языке.

New-AzureSqlDatabaseServerContext

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

New-AzureSqlDatabaseServerContext

Creates a new connection context to the specified SQL Database Server by using SQL Server authentication or certificate-based authentication.

Syntax

Parameter Set: ByServerNameWithSqlAuth
New-AzureSqlDatabaseServerContext [-ServerName] <String> [-Credential] <PSCredential> [ <CommonParameters>]

Parameter Set: ByFullyQualifiedServerNameWithCertAuth
New-AzureSqlDatabaseServerContext [-FullyQualifiedServerName] <String> [-UseSubscription] [[-SubscriptionData] <SubscriptionData> ] [ <CommonParameters>]

Parameter Set: ByFullyQualifiedServerNameWithSqlAuth
New-AzureSqlDatabaseServerContext [-FullyQualifiedServerName] <String> [-Credential] <PSCredential> [ <CommonParameters>]

Parameter Set: ByManageUrlWithSqlAuth
New-AzureSqlDatabaseServerContext [-ManageUrl] <Uri> [-Credential] <PSCredential> [-ServerName <String> ] [ <CommonParameters>]

Parameter Set: ByServerNameWithCertAuth
New-AzureSqlDatabaseServerContext [-ServerName] <String> [-UseSubscription] [[-SubscriptionData] <SubscriptionData> ] [ <CommonParameters>]




Detailed Description

Use the New-AzureSqlDatabaseServerContext cmdlet with SQL Server authentication to create a new connection context to the specified SQL Database Server by using the specified credentials. The SQL Database Server may be specified by name, by the fully-qualified name, or by URL. The credential can be specified using the Get-Credential cmdlet that prompts you to specify the user name and password in a dialog box.

Use the New-AzureSqlDatabaseServerContext cmdlet with certificate-based authentication to create a new connection context to the specified SQL Database Server by using the specified Windows Azure subscription data. The SQL Database Server may be specified by name or by the fully-qualified name. The subscription data can either be specified as a parameter or it can be retrieved from the current Windows Azure subscription (use the Select-AzureSubscription cmdlet to select the current Windows Azure subscription).

Parameters

-Credential<PSCredential>

A credential object that provides SQL Server authentication for the user to access the server.


Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-FullyQualifiedServerName<String>

The fully qualified domain name (FQDN) name for the SQL Database Server. For example, ServerName.database.windows.net.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ManageUrl<Uri>

The URL to access the Windows Azure SQL Database Management Portal for the server.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ServerName<String>

The name of the SQL Database Server.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-SubscriptionData<SubscriptionData>

The Windows Azure subscription data object to be used for creating the connection context. The subscription value specified for the parameter will be used for creating the connection context. If you do not use this parameter, the cmdlet uses the current Windows Azure subscription (set using the Select-AzureSubscription cmdlet) to create the connection context.


Aliases

none

Required?

false

Position?

3

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-UseSubscription

Indicates that Windows Azure subscription will be used for creating the connection context.


Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Microsoft.WindowsAzure.Management.SqlDatabase.Services.Server.IServerDataServiceContext

Notes

  • If you authenticated without specifying a domain, then if you are using PowerShell 2.0, the Get-Credential cmdlet returns a backslash prepended to the username, for example, "\user" (PowerShell 3.0 does not add the backslash). This backslash is not recognized by the -Credential parameter of the New-AzureSqlDatabaseServerContext cmdlet. To remove it, use code similar to the following:

    C:\PS>$cred = Get-Credential

    C:\PS>$cred = New-Object -TypeName 'System.Management.Automation.PSCredential' -ArgumentList $cred.Username.Replace("\",""),$cred.Password

Examples

-------------------------- EXAMPLE 1 --------------------------

This example uses the SQL Server authentication.
It prompts the user for server administrator credentials, connects to the specified SQL Database Server, "lpqd0zbr8y", using those credentials, and creates a new database, “Database1”, on the server.


C:\PS>$cred = Get-CredentialC:\PS>$ctx = New-AzureSqlDatabaseServerContext -ServerName "lpqd0zbr8y" -credential $credC:\PS>$database1 = New-AzureSqlDatabase -ConnectionContext $ctx -DatabaseName "Database1" -MaxSizeGB 50 -Collation "SQL_Latin1_General_CP1_CI_AS"

-------------------------- EXAMPLE 2 --------------------------

This example uses the certificate-based authentication.
The first four commands set common parameters including a subscription ID and certificate for the subscription "mySubscription". These four commands need to be run once per subscription per machine.
The rest of the commands select the subscription "mySubscription" to be designated as the current subscription, and then the current subscription is used to create the connection context to the specified SQL Database Server, "lpqd0zbr8y".


C:\PS>$subId = <Subscription ID>C:\PS>$thumbprint = <Certificate Thumbprint>C:\PS>$myCert = Get-Item Cert:\CurrentUser\My\$thumbprintC:\PS> Set-AzureSubscription -SubscriptionName "mySubscription" -SubscriptionId $subId -Certificate $myCert---------------------------------------------------------C:\PS>Select-AzureSubscription -SubscriptionName "mySubscription"C:\PS>$ctx = New-AzureSqlDatabaseServerContext -ServerName "lpqd0zbr8y" -UseSubscription

Related topics

Корпорация Майкрософт проводит интернет-опрос, чтобы выяснить ваше мнение о веб-сайте MSDN. Если вы желаете принять участие в этом интернет-опросе, он будет отображен при закрытии веб-сайта MSDN.

Вы хотите принять участие?
Показ:
© 2014 Microsoft