Azure-pipelines-tasks: Deploy Connection Strings using Azure App Service Deploy

Created on 6 Dec 2018  路  7Comments  路  Source: microsoft/azure-pipelines-tasks

Environment

  • Server - Azure Pipelines
  • Agent - Hosted

    • Hosted VS2017

  • Task - Azure App Service Deploy (Preview)

    • Version 4.* (preview)

Issue Description

I am attempting to deploy connection strings to an Azure Function App. I am able to specify app settings, but cannot figure out how to make my connection string show up in the connection string settings.

I would specify it manually through the Azure portal, but each new deployment wipes out the connection string, which would cause a manual step, which could be easily missed.

Is there a method of specifying a connection string for the connection strings settings?

AzureAppService Release enhancement

Most helpful comment

az webapp config connection-string set -g MyResourceGroup -n MyUniqueApp -t mysql --settings mysql1='Server=myServer;Database=myDB;Uid=myUser;Pwd=myPwd;'

Reference

All 7 comments

@gwoody1984 , the story is in out backlog and the feature will be added soon.
In the meantime, you can add AZ CLI (or) Azure PowerShell task to update connection strings from Azure Pieplines.

It'd be great to have an example to follow while there is no support for setting connection string via the task.

az webapp config connection-string set -g MyResourceGroup -n MyUniqueApp -t mysql --settings mysql1='Server=myServer;Database=myDB;Uid=myUser;Pwd=myPwd;'

Reference

Thanks, that'd help anyone having the same issue.

For any googlers struggling with this in the mean time, you can set your connection strings using the Azure Powershell task with script:
$connStrings = @{ Default = @{ Type = "Custom"; Value = "$(DefaultConnStr)"}; AnotherDb = @{ Type = "Custom"; Value = "yourconnectionstring"}}; Set-AzureRmWebApp -ResourceGroupName YourResourceGroupName -Name YourWebAppName -ConnectionStrings $connStrings

well initialy when you create the function, you should have a local.settings.json file. What ever values are in there are convereted to the appsettings.json file. If you have the connection string in the local json file it will be added to the appsettigns.json, which will then allow you to change values for the server/db/user/pass per the environments youre deploying to.

In my .net core based web app, I change the values to the appsettings.json before I deploy the webapp as I have my entity framework migration that requires the connection string to already have the right values in the connection string before I run the web app deployment.

We have a new task for updating connection strings: https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/AzureAppServiceSettingsV1 now.
I hope this solves your query.

Was this page helpful?
0 / 5 - 0 ratings