Cannot Delete All Azure Website Connection Strings

限于喜欢 提交于 2019-12-07 07:03:17

问题


For a website my team are currently working on we're trying to write some PowerShell automation to temporarily override a connection string which is otherwise usually in Web.config, and then at a later point delete it.

However, using both the PowerShell cmdlets and the Azure REST APIs, we don't seem to be able to ever reset the connection strings set to be empty. Whenever we try to delete it either the command says it succeeds but doesn't delete it, or the requests is rejected as invalid.

It's possible to delete all the connection strings using the Management Portal, so what are we missing that means we can't do it programmatically?

Here's an example PowerShell command we're using that isn't doing what we want:

$website = Get-AzureWebsite $websiteName -slot $websiteSlot
$connectionStrings = $website.ConnectionStrings

$result = $connectionStrings.Remove(($connectionStrings | Where-Object {$_.Name -eq $connectionStringName}))

Set-AzureWebsite $websiteName -slot $websiteSlot -ConnectionStrings $connectionStrings

回答1:


I know this is really late.

I have faced the same situation.We are able to update the App settings but not the connection strings.I found the solution.Since it doesn't have an answer, I thought it would be good to update it..

As per the git-hub source, the hash-table(nested) needs to be in the format of

@{ KeyName = @{ Type = "MySql"; Value = "MySql Connection string"}};

after which I ran the code to update the App, it worked. Below is the whole code

$list =  @{ ConnectionString1 = @{ Type = "MySql"; Value = "MySql Connection string"}};

set-AzureRMWebAppSlot -ResourceGroupName "resourceGroup" -Name "devTest" -ConnectionStrings $list -slot "production"


来源:https://stackoverflow.com/questions/29648327/cannot-delete-all-azure-website-connection-strings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!