无法删除所有Azure网站连接字符串 [英] Cannot Delete All Azure Website Connection Strings

查看:89
本文介绍了无法删除所有Azure网站连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的团队目前正在研究的网站,我们正在尝试编写一些PowerShell自动化功能来临时覆盖通常在Web.config中的连接字符串,然后在以后删除它.

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.

但是,同时使用PowerShell cmdlet和Azure REST API,我们似乎无法将连接字符串设置为空.每当我们尝试删除它时,要么命令说它成功但不删除它,要么请求被拒绝为无效.

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?

以下是我们正在使用的示例PowerShell命令,该命令没有执行我们想要的操作:

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

推荐答案

我知道这真的很晚.

我遇到过同样的情况.我们能够更新App设置,但不能更新连接字符串.我找到了解决方案.由于它没有答案,所以我认为更新它会很好..

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..

按照 git-hub源,哈希表(嵌套)的格式必须为

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"

这篇关于无法删除所有Azure网站连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆