-
Notifications
You must be signed in to change notification settings - Fork 4k
Websites: Adding support for MSI & Https in slots #5986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,10 +89,17 @@ public class SetAzureWebAppSlotCmdlet : WebAppSlotBaseCmdlet | |
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] | ||
public SwitchParameter AsJob { get; set; } | ||
|
||
[Parameter(ParameterSetName = ParameterSet1Name, Mandatory = false, HelpMessage = "Enable MSI on an existing azure webapp")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a PATCH or a PUT? If it is a PATCH, this is OK. If it is a PUT, then these should be switch parameters There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a PATCH Mark, but during our commandlet review (https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/51)we concluded that
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can i propose that we update all the properties of the SetWebApp & SetWebAppSlot to use the switch parameter as a separate change, i agree switch parameter is the valid PowerShell way , however to have consistency we should change all which i want to avoid this time, since its a bigger change. Let me know your thoughts! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For PATCH boolean parameters are acceptable, for PUT they are not. I am OK with this for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you this is the issue to track this #6066 |
||
public bool AssignIdentity { get; set; } | ||
|
||
[Parameter(ParameterSetName = ParameterSet1Name, Mandatory = false, HelpMessage = "Enable/disable redirecting all traffic to HTTPS on an existing azure webapp")] | ||
public bool HttpsOnly { get; set; } | ||
|
||
public override void ExecuteCmdlet() | ||
{ | ||
base.ExecuteCmdlet(); | ||
SiteConfig siteConfig = null; | ||
Site site = null; | ||
string location = null; | ||
switch (ParameterSetName) | ||
{ | ||
|
@@ -128,12 +135,41 @@ public override void ExecuteCmdlet() | |
// Update web app configuration | ||
WebsitesClient.UpdateWebAppConfiguration(ResourceGroupName, location, Name, Slot, siteConfig, AppSettings.ConvertToStringDictionary(), ConnectionStrings.ConvertToConnectionStringDictionary()); | ||
|
||
if (parameters.Any(p => CmdletHelpers.SiteParameters.Contains(p))) | ||
{ | ||
|
||
site = new Site | ||
{ | ||
Location = location, | ||
ServerFarmId = WebApp.ServerFarmId, | ||
Identity = parameters.Contains("AssignIdentity") && AssignIdentity ? new ManagedServiceIdentity("SystemAssigned", null, null) : WebApp.Identity, | ||
HttpsOnly = parameters.Contains("HttpsOnly") ? HttpsOnly : WebApp.HttpsOnly | ||
}; | ||
|
||
Dictionary<string, string> appSettings = WebApp.SiteConfig?.AppSettings?.ToDictionary(x => x.Name, x => x.Value); | ||
if (parameters.Contains("AssignIdentity")) | ||
{ | ||
|
||
// Add or update the appsettings property | ||
appSettings["WEBSITE_DISABLE_MSI"] = (!AssignIdentity).ToString(); | ||
WebsitesClient.UpdateWebAppConfiguration(ResourceGroupName, location, Name, Slot, WebApp.SiteConfig, appSettings, | ||
WebApp.SiteConfig.ConnectionStrings. | ||
ToDictionary(nvp => nvp.Name, | ||
nvp => new ConnStringValueTypePair | ||
{ | ||
Type = nvp.Type.Value, | ||
Value = nvp.ConnectionString | ||
}, | ||
StringComparer.OrdinalIgnoreCase)); | ||
} | ||
WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, WebApp.ServerFarmId, site); | ||
} | ||
|
||
if (parameters.Contains("AppServicePlan")) | ||
{ | ||
WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, AppServicePlan); | ||
} | ||
|
||
|
||
break; | ||
case ParameterSet2Name: | ||
// Web app is direct or pipeline input | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests for these new parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it for the webapp version