Skip to content

Commit 0ad8825

Browse files
committed
Fixing a bug with import/export cmdlets not able to be used with v12 server.
Fixing a bug where some cultures would convert 12.0 to "12,0" causing failures.
1 parent 732f1c1 commit 0ad8825

File tree

8 files changed

+69
-16
lines changed

8 files changed

+69
-16
lines changed

src/ServiceManagement/Sql/Commands.SqlDatabase/Commands.SqlDatabase.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
<Compile Include="Services\Common\SqlDatabaseExceptionHandler.cs" />
197197
<Compile Include="Services\Common\ManagementServiceExceptionInfo.cs" />
198198
<Compile Include="Services\Constants.cs" />
199+
<Compile Include="Services\Server\ISqlServerConnectionInformation.cs" />
199200
<Compile Include="Services\Server\RecoverableDatabaseExtensions.cs" />
200201
<Compile Include="Services\Server\DatabaseCopyExtensions.cs" />
201202
<Compile Include="Services\ImportExport\ImportExportRequest.cs" />

src/ServiceManagement/Sql/Commands.SqlDatabase/Database/Cmdlet/StartAzureSqlDatabaseExport.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,13 @@ public class StartAzureSqlDatabaseExport : SqlDatabaseCmdletBase
5151
#region Parameters
5252

5353
/// <summary>
54-
/// Gets or sets the context for connecting to the server
54+
/// Gets or sets the connection information for connecting to the server
5555
/// </summary>
5656
[Parameter(Mandatory = true, Position = 0,
57-
HelpMessage = "The context for connecting to the server")]
57+
HelpMessage = "The connection information for connecting to a server. " +
58+
"This can be an Azure SQL Server connection context that uses username with password.")]
5859
[ValidateNotNullOrEmpty]
59-
public ServerDataServiceSqlAuth SqlConnectionContext { get; set; }
60+
public ISqlServerConnectionInformation SqlConnectionContext { get; set; }
6061

6162
/// <summary>
6263
/// Gets or sets the destination storage container for the blob

src/ServiceManagement/Sql/Commands.SqlDatabase/Database/Cmdlet/StartAzureSqlDatabaseImport.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,13 @@ public class StartAzureSqlDatabaseImport : SqlDatabaseCmdletBase
5151
#region Parameters
5252

5353
/// <summary>
54-
/// Gets or sets the context for connecting to the server
54+
/// Gets or sets the connection information for connecting to the server
5555
/// </summary>
5656
[Parameter(Mandatory = true, Position = 0,
57-
HelpMessage = "The context for connecting to the server")]
57+
HelpMessage = "The connection information for connecting to a server. " +
58+
"This can be an Azure SQL Server connection context that uses username with password.")]
5859
[ValidateNotNullOrEmpty]
59-
public ServerDataServiceSqlAuth SqlConnectionContext { get; set; }
60+
public ISqlServerConnectionInformation SqlConnectionContext { get; set; }
6061

6162
/// <summary>
6263
/// Gets or sets the storage container object containing the blob

src/ServiceManagement/Sql/Commands.SqlDatabase/Server/Cmdlet/NewAzureSqlDatabaseServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ internal SqlDatabaseServerContext NewAzureSqlDatabaseServerProcess(
117117
Location = location,
118118
AdministratorUserName = adminLogin,
119119
AdministratorPassword = adminLoginPassword,
120-
Version = version.HasValue ? version.Value.ToString("F1") : null
120+
Version = version.HasValue ? version.Value.ToString("F1", CultureInfo.InvariantCulture) : null
121121
});
122122

123123
var newServer = sqlManagementClient.Servers.List().Servers.Where(s => s.Name == response.ServerName).FirstOrDefault();
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Common;
16+
17+
namespace Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server
18+
{
19+
/// <summary>
20+
/// Interface for defining information needed to connect to a server using SQL auth.
21+
/// </summary>
22+
public interface ISqlServerConnectionInformation
23+
{
24+
/// <summary>
25+
/// The name of the server
26+
/// </summary>
27+
string ServerName { get; }
28+
29+
/// <summary>
30+
/// The SQL authentication credentials.
31+
/// </summary>
32+
SqlAuthenticationCredentials SqlCredentials { get; }
33+
}
34+
}

src/ServiceManagement/Sql/Commands.SqlDatabase/Services/Server/ServerDataServiceSqlAuth.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server
3131
/// <summary>
3232
/// Implementation of the <see cref="IServerDataServiceContext"/> with Sql Authentication.
3333
/// </summary>
34-
public partial class ServerDataServiceSqlAuth : ServerDataServiceContext, IServerDataServiceContext
34+
public partial class ServerDataServiceSqlAuth : ServerDataServiceContext, IServerDataServiceContext, ISqlServerConnectionInformation
3535
{
3636
#region Constants
3737

src/ServiceManagement/Sql/Commands.SqlDatabase/Services/Server/SqlAuthContextFactory.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ public static IServerDataServiceContext GetContext(
9292
context = new TSqlConnectionContext(
9393
sessionActivityId,
9494
manageUrl.Host,
95-
credentials.UserName,
96-
credentials.Password);
95+
credentials);
9796
}
9897
else
9998
{

src/ServiceManagement/Sql/Commands.SqlDatabase/Services/Server/TSqlConnectionContext.cs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Common;
1516
using System;
1617
using System.Collections.Generic;
1718
using System.Data.Common;
@@ -22,7 +23,7 @@
2223

2324
namespace Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server
2425
{
25-
public class TSqlConnectionContext : IServerDataServiceContext
26+
public class TSqlConnectionContext : IServerDataServiceContext, ISqlServerConnectionInformation
2627
{
2728
/// <summary>
2829
/// Timeout duration for commands
@@ -122,6 +123,17 @@ public string ServerName
122123
}
123124
}
124125

126+
/// <summary>
127+
/// Gets the SQL credentials for connecting to the server.
128+
/// </summary>
129+
public SqlAuthenticationCredentials SqlCredentials
130+
{
131+
get
132+
{
133+
return credentials;
134+
}
135+
}
136+
125137
/// <summary>
126138
/// Contains the connection string necessary to connect to the server
127139
/// </summary>
@@ -142,6 +154,11 @@ public string ServerName
142154
/// </summary>
143155
private string serverName;
144156

157+
/// <summary>
158+
/// The sql connection credetials
159+
/// </summary>
160+
private SqlAuthenticationCredentials credentials;
161+
145162
/// <summary>
146163
/// Helper function to generate the SqlConnectionStringBuilder
147164
/// </summary>
@@ -183,14 +200,14 @@ private DbConnection CreateConnection()
183200
/// <summary>
184201
/// Creates an instance of a SQLAuth to TSql class
185202
/// </summary>
186-
/// <param name="fullyQualifiedServerName"></param>
187-
/// <param name="username"></param>
188-
/// <param name="password"></param>
189-
public TSqlConnectionContext(Guid sessionActivityId, string fullyQualifiedServerName, string username, string password)
203+
/// <param name="fullyQualifiedServerName">The full server name</param>
204+
/// <param name="credentials">The login credentials for the server</param>
205+
public TSqlConnectionContext(Guid sessionActivityId, string fullyQualifiedServerName, SqlAuthenticationCredentials credentials)
190206
{
191207
this.sessionActivityId = sessionActivityId;
192208
this.clientRequestId = SqlDatabaseCmdletBase.GenerateClientTracingId();
193-
builder = GenerateSqlConnectionBuilder(fullyQualifiedServerName, username, password);
209+
this.credentials = credentials;
210+
builder = GenerateSqlConnectionBuilder(fullyQualifiedServerName, credentials.UserName, credentials.Password);
194211
}
195212

196213
/// <summary>

0 commit comments

Comments
 (0)