File tree Expand file tree Collapse file tree 5 files changed +49
-7
lines changed
Tasks/SqlAzureDacpacDeploymentV1
Strings/resources.resjson/en-US Expand file tree Collapse file tree 5 files changed +49
-7
lines changed Original file line number Diff line number Diff line change @@ -270,10 +270,12 @@ function Run-SqlCmd {
270270 }
271271 }
272272 elseif ($authenticationType -eq " connectionString" ) {
273+ Check- ConnectionString
273274 $commandToRun = " Invoke-Sqlcmd -connectionString `" $connectionString `" "
274275 $commandToLog = " Invoke-Sqlcmd -connectionString `" **********`" "
275276 }
276277 elseif ($authenticationType -eq " aadAuthenticationPassword" -or $authenticationType -eq " aadAuthenticationIntegrated" ) {
278+ Check- connectionString
277279 $connectionString = Get-AADAuthenticationConnectionString - authenticationType $authenticationType - serverName $serverName - databaseName $databaseName - sqlUserName $sqlUserName - sqlPassword $sqlPassword
278280 $commandToRun = " Invoke-Sqlcmd -connectionString `" $connectionString `" "
279281 $commandToLog = " Invoke-Sqlcmd -connectionString `" $connectionString `" "
@@ -286,6 +288,14 @@ function Run-SqlCmd {
286288 Invoke-Expression $commandToRun
287289}
288290
291+ function Check-ConnectionString
292+ {
293+ if (-not (CmdletHasMember - cmdlet Invoke-SQlCmd - memberName " connectionString" ))
294+ {
295+ throw (Get-VstsLocString - Key " SAD_InvokeSQLCmdNotSupportingConnectionString" )
296+ }
297+ }
298+
289299function Get-AgentIPRange
290300{
291301 param (
Original file line number Diff line number Diff line change 7676 "loc.messages.SAD_DacpacFilePath": "DACPAC file path:",
7777 "loc.messages.SAD_BacpacFilePath": "BACPAC file path:",
7878 "loc.messages.SAD_PublishProfilePath": "Publish profile path:",
79- "loc.messages.SAD_DriftReportWarning": "While generating a Drift Report of the database, ensure that the database is registered as a Data-tier Application."
79+ "loc.messages.SAD_DriftReportWarning": "While generating a Drift Report of the database, ensure that the database is registered as a Data-tier Application.",
80+ "loc.messages.SAD_InvokeSQLCmdNotSupportingConnectionString": "Imported Invoke-Sqlcmd doesn't support connectionString. Install SQLServer PS module."
8081}
Original file line number Diff line number Diff line change @@ -332,6 +332,33 @@ function EscapeSpecialChars
332332# Function to import SqlPS module & avoid directory switch
333333function Import-Sqlps {
334334 Push-Location
335- Import-Module SqlPS - ErrorAction ' SilentlyContinue' 3>&1 | Out-Null
335+
336+ $modules = Get-Module - Name SQLServer - ListAvailable
337+ if ($modules )
338+ {
339+ Import-Module SQLServer - ErrorAction ' SilentlyContinue' 3>&1 | Out-Null
340+ Write-Verbose " Imported SQLServer PS module."
341+ } else {
342+ Write-Verbose " SQLServer PS module is not installed. Importing SQLPS"
343+ Import-Module SqlPS - ErrorAction ' SilentlyContinue' 3>&1 | Out-Null
344+ }
345+
336346 Pop-Location
337347}
348+
349+ function CmdletHasMember {
350+ [CmdletBinding ()]
351+ param (
352+ [Parameter (Mandatory = $true )]
353+ [string ]$cmdlet ,
354+ [Parameter (Mandatory = $true )]
355+ [string ]$memberName )
356+ try {
357+ $hasMember = (gcm $cmdlet ).Parameters.Keys.Contains($memberName )
358+ return $hasMember
359+ }
360+ catch
361+ {
362+ return $false ;
363+ }
364+ }
Original file line number Diff line number Diff line change 33 "name" : " SqlAzureDacpacDeployment" ,
44 "friendlyName" : " Azure SQL Database Deployment" ,
55 "description" : " Deploy Azure SQL DB using DACPAC or run scripts using SQLCMD" ,
6+ "helpUrl" : " https://aka.ms/sqlazuredeployreadme" ,
67 "helpMarkDown" : " [More Information](https://aka.ms/sqlazuredeployreadme)" ,
78 "category" : " Deploy" ,
89 "visibility" : [
1617 "version" : {
1718 "Major" : 1 ,
1819 "Minor" : 3 ,
19- "Patch" : 11
20+ "Patch" : 12
2021 },
2122 "demands" : [
2223 " sqlpackage"
362363 "SAD_DacpacFilePath" : " DACPAC file path:" ,
363364 "SAD_BacpacFilePath" : " BACPAC file path:" ,
364365 "SAD_PublishProfilePath" : " Publish profile path:" ,
365- "SAD_DriftReportWarning" : " While generating a Drift Report of the database, ensure that the database is registered as a Data-tier Application."
366+ "SAD_DriftReportWarning" : " While generating a Drift Report of the database, ensure that the database is registered as a Data-tier Application." ,
367+ "SAD_InvokeSQLCmdNotSupportingConnectionString" : " Imported Invoke-Sqlcmd doesn't support connectionString. Install SQLServer PS module."
366368 }
367369}
Original file line number Diff line number Diff line change 33 "name" : " SqlAzureDacpacDeployment" ,
44 "friendlyName" : " ms-resource:loc.friendlyName" ,
55 "description" : " ms-resource:loc.description" ,
6+ "helpUrl" : " https://aka.ms/sqlazuredeployreadme" ,
67 "helpMarkDown" : " ms-resource:loc.helpMarkDown" ,
78 "category" : " Deploy" ,
89 "visibility" : [
1617 "version" : {
1718 "Major" : 1 ,
1819 "Minor" : 3 ,
19- "Patch" : 11
20+ "Patch" : 12
2021 },
2122 "demands" : [
2223 " sqlpackage"
362363 "SAD_DacpacFilePath" : " ms-resource:loc.messages.SAD_DacpacFilePath" ,
363364 "SAD_BacpacFilePath" : " ms-resource:loc.messages.SAD_BacpacFilePath" ,
364365 "SAD_PublishProfilePath" : " ms-resource:loc.messages.SAD_PublishProfilePath" ,
365- "SAD_DriftReportWarning" : " ms-resource:loc.messages.SAD_DriftReportWarning"
366+ "SAD_DriftReportWarning" : " ms-resource:loc.messages.SAD_DriftReportWarning" ,
367+ "SAD_InvokeSQLCmdNotSupportingConnectionString" : " ms-resource:loc.messages.SAD_InvokeSQLCmdNotSupportingConnectionString"
366368 }
367- }
369+ }
You can’t perform that action at this time.
0 commit comments