Skip to content

Commit 132cb06

Browse files
committed
Re-recording RemoveWebAppTest & adding the changes from pull request Azure#5471 for identity & httpsOnly property
1 parent 0dd8638 commit 132cb06

File tree

2 files changed

+214
-179
lines changed
  • src/ResourceManager/Websites

2 files changed

+214
-179
lines changed

src/ResourceManager/Websites/Commands.Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests/TestRemoveWebApp.json

Lines changed: 203 additions & 173 deletions
Large diffs are not rendered by default.

src/ResourceManager/Websites/Commands.Websites/Cmdlets/WebApps/SetAzureWebApp.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ public class SetAzureWebAppCmdlet : WebAppBaseCmdlet
9797
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
9898
public SwitchParameter AsJob { get; set; }
9999

100-
[Parameter(ParameterSetName = ParameterSet1Name, Mandatory = false, HelpMessage = "Enable MSI on an existing azure webapp or functionapp")]
100+
[Parameter(ParameterSetName = ParameterSet1Name, Mandatory = false, HelpMessage = "Enable MSI on an existing azure webapp")]
101101
public SwitchParameter AssignIdentity { get; set; }
102102

103-
[Parameter(ParameterSetName = ParameterSet1Name, Mandatory = false, HelpMessage = "Enable/disable redirecting all traffic to HTTPS on an existing azure webapp or functionapp")]
103+
[Parameter(ParameterSetName = ParameterSet1Name, Mandatory = false, HelpMessage = "Enable/disable redirecting all traffic to HTTPS on an existing azure webapp")]
104104
public SwitchParameter HttpsOnly { get; set; }
105105

106106
public override void ExecuteCmdlet()
@@ -149,13 +149,13 @@ public override void ExecuteCmdlet()
149149
{
150150
Location = location,
151151
ServerFarmId = WebApp.ServerFarmId,
152-
Identity = parameters.Contains("AssignIdentity") ? new ManagedServiceIdentity("SystemAssigned", null, null) : WebApp.Identity,
153-
HttpsOnly = parameters.Contains("HttpsOnly")
152+
Identity = AssignIdentity.IsPresent ? new ManagedServiceIdentity("SystemAssigned", null, null) : WebApp.Identity,
153+
HttpsOnly = HttpsOnly.IsPresent
154154
};
155155

156-
if (parameters.Contains("AssignIdentity"))
156+
Dictionary<string, string> appSettings = WebApp.SiteConfig?.AppSettings?.ToDictionary(x => x.Name, x => x.Value);
157+
if (AssignIdentity.IsPresent)
157158
{
158-
Dictionary<string, string> appSettings = WebApp.SiteConfig?.AppSettings?.ToDictionary(x => x.Name, x => x.Value);
159159

160160
// Add or update the appsettings property
161161
appSettings["WEBSITE_DISABLE_MSI"] = (!AssignIdentity).ToString();
@@ -169,6 +169,11 @@ public override void ExecuteCmdlet()
169169
},
170170
StringComparer.OrdinalIgnoreCase));
171171
}
172+
else
173+
{
174+
// disabling the identity property updates the siteconfig only
175+
appSettings["WEBSITE_DISABLE_MSI"] = (!AssignIdentity.IsPresent).ToString();
176+
}
172177

173178
WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, null, WebApp.ServerFarmId, site);
174179
}

0 commit comments

Comments
 (0)