0

I've deployed an Azure Web App and Azure SQL Database using PowerShell. At the moment I have the following code with a dummy value that sets a sql connection string for my web app:

$connectionStrings = @{

"sqlConnection"= @{
    "value"="placeholder";
    "type"="3"

}
}

I would like to be able to enter a proper sql connection string for my azure sql database, like the following: Server=tcp:example.database.useastcloudapi.net;Database=ExampleDB;User Id=Admin;Password=Something123!;

The issue im having is entering/referencing the variables I've created containing the sql user account, password and server FQDN into the connection string value above. Ideally, I'd like to do something like the following (I know that its incorrect but I want to reference the variables im using):

$connectionStrings = @{

"sqlConnection"= @{
    "value"="Server=tcp:"[$sqlServer];"Database="[$sqlDatabase];"User Id="[$sqlUser];
    "type"="3"

}
}

I don't have much experience with powershell and im not a developer so I would appreciate any help or suggestions.

Thanks!

jrd1989
  • 628
  • 10
  • 35
  • 1
    [About Quoting Rules](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules). `"value"="Server=tcp:$sqlServer;Database=$sqlDatabase;User Id=$sqlUser;Password=$Password;"` could work… – JosefZ Oct 20 '20 at 20:59
  • That worked for me but now my issue is the $sqlServer variable only returns the sql server name and not the full server name - servername.database.region.net. I used Get-AzSqlDatabaseSecureConnectionPolicy to get the full server name (ProxyDnsName) value but when I reference this new variable in the conn string it also adds 'ProxyDnsName' along with the server name. Is there a way to remove ProxyDnsName from being entered in the conn string? – jrd1989 Oct 21 '20 at 15:18

0 Answers0