Managing Connections Deploying the Azure Cloud Service

I have an azure cloud service project that includes one work role and one web role. I need to have both a deployment and a real-time deployment, but I need them to have different connection strings, because the working role generates a lot of data, which is reported by the web application, and I do not want to have test data in the production process.

What is the best way to configure this so that I can quickly swap or advance from the live stage and update the connection strings without republishing them from the visual studio using a different configuration.

+4
source share
4 answers

You can write a PowerShell script that calls the Azure Management REST API and modifies the connection strings.

    $restEndpoint = "https://management.core.windows.net/$subscriptionId/services/webspaces/$webspace/sites/$website/slotConfigNames"

    $appSettings = $appSettingNames -replace ",", "','"
    $connectionStrings = $connectionStringNames -replace ",", ""","""
    $payload = "{""AppSettingNames"": [""$appSettingNames""], ""ConnectionStringNames"": [""$connectionStrings""]}"

    Invoke-WebRequest -Uri $restEndpoint -Body $payload -CertificateThumbprint $certThumbprint -ContentType "application/json" -Headers @{ "x-ms-version" = "2014-04-01" } -Method POST
+1
source

As far as I know, there is no automated toolkit for this. When you change, your configuration also swaps. As far as I understand, you do not want to change the configuration, but just an application.

You may need to create your own swap tool that will connect to the management API and swap as you want.

0
source

, swap/slot VIP, Azure Cloud Services ( -/ ).

OnRoleStart .

, , , . , , web.config.

0

. (Test and Live) (Staging and Production CS).

, .

You should have two sets of connection strings in web.config (StagingConStr and ProductionCOnStr). Based on the host (livesite.cloudapp.net or stagingsite.cloudapp.net) you may find that it is live or in production. Based on discovery, you can use a different connection string.

Hope this helps ...

0
source

Source: https://habr.com/ru/post/1570284/


All Articles