0
votes

I try to update my database on SQL Azure from VSTS.

I need to apply a firewall rules during the migration and remove it after.

I'm using a VSTS Azure PowerShell Task, I've configured it and I try this command to add a rule:

New-AzureSqlDatabaseServerFirewallRule -ServerName $serverName -RuleName $firewallRule -StartIpAddress $currentPublicIp -EndIpAddress $currentPublicIp

The task fails with this error message:

##[error]No default subscription has been designated. Use Select-AzureSubscription -Default <subscriptionName> to set the default subscription.

The task is starting with this in logs:

##[command]Add-AzureRMAccount -ServicePrincipal -Tenant ******** -Credential System.Management.Automation.PSCredential -Environment AzureCloud
##[command]Select-AzureRMSubscription -SubscriptionId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -TenantId ********
1
In VSTS, you selected a ARM subscription, but New-AzureSqlDatabaseServerFirewallRule is a classic cmdlet. You should use New-AzureRmSqlServerFirewallRule -ResourceGroupName "" -ServerName "" -FirewallRuleName "Rule01" -StartIpAddress "192.168.0.198" -EndIpAddress "192.168.0.199"Shui shengbao
Thanks Walter, just to know classic cmdlet are supposed to be deprecated in favor of ARM or both have their advantages?JuChom
Maybe you could refer to this link.Shui shengbao

1 Answers

2
votes

You should use ARM cmdlet for the SQL DB, not ASM one. Notice the RM in cmdlets.

New-AzureRmSqlServerFirewallRule
Set-AzureRmSqlServerFirewallRule