Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically create new connection strings for web applications Azure

I am attempting to automate a workflow in our Azure environment.

We have several web applications with connectionstrings to several databases. Each new customer recives a new database.

I've hit a snag in the script with our connectionstrings. I want the script to update all web applications and add a new connectionstring for the newly created customer db.

The problem is "Set-Azurermwebapp -Name -ResourceGroup -ConnectionStrings" takes a hashtable which replaces any previously configured data.

I would only like to append a new connectionstring, or get the previously configered cstrings and add them to an array, then replacing all data.

Example code;

$test= @{"Type"="Custom"; "Value" = "TestValue"} 
$Connectionstring=@{"test"=$test }

Set-AzureRmWebApp 
        -Name "testapp" 
        -ResourceGroupName "testgrp" 
        -ConnectionStrings $Connectionstring"

Any ideas here?

like image 406
J Smith Avatar asked Mar 23 '26 15:03

J Smith


1 Answers

$connStrings =  @{ 
   AzureWebJobsDashboard = @{ 
       Type = "Custom"; 
       Value = $AzureWebJobsDashboard 
   };
   AzureWebJobsStorage = @{ 
       Type = "MySql"; 
       Value = $connstring
   }
};

Set-AzureRMWebApp -Name $webServiceName -ResourceGroupName $rgName -ConnectionStrings $connStrings

Cannot Delete All Azure Website Connection Strings

like image 61
Srinivasa Rao Nalluri Avatar answered Mar 26 '26 04:03

Srinivasa Rao Nalluri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!