question

kirtibansal-3349 avatar image
1 Vote"
kirtibansal-3349 asked AlbertoMorillo edited

##[error]A parameter cannot be found that matches parameter name 'FirewallRuleName'.

Hi Team,

Have followed the steps mentioned in below documentation for Azure Sql database deployment using azure devops pipeline.

https://docs.microsoft.com/en-us/azure/devops/pipelines/targets/azure-sqldb?view=azure-devops&tabs=yaml

I am not able to run the "CLASSIC" SetAzureFirewallRule.ps1 (to create and update firewall rules), it is giving error as "##[error]A parameter cannot be found that matches parameter name 'FirewallRuleName'"

Any suggestions on this??

ARM one is working fine, until or unless it doesnot have the update step for firewall?.
Have tried with defining parameter inside the functions and viceversa but it is giving the same error.

azure-sql-database
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AlbertoMorillo avatar image
0 Votes"
AlbertoMorillo answered AlbertoMorillo edited

Please change "-FirewallRuleName" by "-RuleName" as described here.



· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for the information. One more query if we use DACPAC task then it is not required to use SetFirewallRule and RemoveFirewall one as the Azure Pipelines agent can communicate with Azure SQL Database, it is required only with SQL Scripts. Correct?


0 Votes 0 ·

If on Azure SQL firewall you set "Allow Azure services and resources to access this server" to Yes then Azure Pipeline should communicate with no issues to Azure SQL.

194972-image.png


0 Votes 0 ·
image.png (4.1 KiB)

Thanks for the information.
I have the run script (https://docs.microsoft.com/en-us/azure/devops/pipelines/targets/azure-sqldb?view=azure-devops&tabs=yaml) --classic
======================================>
And in AzureDevopsYML file as
- task: AzurePowerShell@2
displayName: Azure PowerShell script for setting up the firewall
inputs:
azureSubscription: '$(AzureSubscription)' ===>here the service connection
ScriptPath: '$(Build.SourcesDirectory)\scripts\SetAzureFirewallRule.ps1'
ScriptArguments: '-ServerName $(ServerName)'
azurePowerShellVersion: LatestVersion

But it is giving the error as ##[error]No default subscription has been designated. Use Select-AzureSubscription -Default <subscriptionName> to set the default subscription.
Have tried to set the subscription in powershell script but it is getting disconnected "Disconnect-AzureRmAccount -Scope Process -ErrorAction Stop" when it tries to run the function.


Any suggestions on this?

0 Votes 0 ·
Show more comments
kirtibansal-3349 avatar image
0 Votes"
kirtibansal-3349 answered kirtibansal-3349 edited

Powershell Script-->
===================================================>
[CmdletBinding(DefaultParameterSetName = 'None')]
param
(
[String] [Parameter(Mandatory = $true)] $ServerName,
[String] $AzureFirewallName = "AzureWebAppFirewall"
)

$ErrorActionPreference = 'Stop'
az login --service-principal -u <app-id> -p <appsecret> --tenant <tenant-id>
function New-AzureSQLServerFirewallRule {
$agentIP = (New-Object net.webclient).downloadstring("https://api.ipify.org")
New-AzureSqlDatabaseServerFirewallRule -StartIPAddress $agentIp -EndIPAddress $agentIp -RuleName $AzureFirewallName -ServerName $ServerName
}
function Update-AzureSQLServerFirewallRule{
$agentIP= (New-Object net.webclient).downloadstring("https://api.ipify.org")
Set-AzureSqlDatabaseServerFirewallRule -StartIPAddress $agentIp -EndIPAddress $agentIp -RuleName $AzureFirewallName -ServerName $ServerName
}
If ((Get-AzureSqlDatabaseServerFirewallRule -ServerName $ServerName -RuleName $AzureFirewallName -ErrorAction SilentlyContinue) -eq $null)
{
New-AzureSQLServerFirewallRule
}
else
{
Update-AzureSQLServerFirewallRule
}

Note: have removed the resourcegroupname as it is giving the same error as giving for FirewallRuleName

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.