【问题标题】:Cannot Delete All Azure Website Connection Strings无法删除所有 Azure 网站连接字符串
【发布时间】:2016-07-27 22:58:38
【问题描述】:

对于我的团队目前正在开发的网站,我们正在尝试编写一些 PowerShell 自动化来临时覆盖通常在 Web.config 中的连接字符串,然后稍后将其删除。

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

可以使用管理门户删除所有连接字符串,那么我们缺少什么意味着我们无法以编程方式执行此操作?

这是我们正在使用的一个示例 PowerShell 命令,但它并没有按照我们的意愿行事:

$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

【问题讨论】:

  • 这对我来说似乎是一个错误。
  • 微软最近表示,新的 Azure 门户由相同的公共 API 驱动,那么如何不通过 PowerShell 而从 UI 中删除设置呢? UI 是如何删除设置的?
  • 我不知道,你得问问 MSFT。但是,这应该适用于国际海事组织。顺便说一句,如果您想关注,这是我昨晚打开的一个问题的链接。 github.com/Azure/azure-powershell/issues/340

标签: powershell azure azure-web-app-service


【解决方案1】:

我知道这真的很晚了。

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

根据git-hub source,哈希表(嵌套)需要采用

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

之后我运行代码来更新应用程序,它工作正常。下面是整个代码

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-16
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 2016-01-26
    • 2016-02-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多