OctopusDeploy / Issues

| Public | Bug reports and known issues for Octopus Deploy and all related tools
https://octopus.com
162 stars 20 forks source link

Once an Azure Web App Slot is picked for an Azure Web App deployment target, it isn't possible to remove it via the UI #7588

Open patrick-smergut-octopus opened 2 years ago

patrick-smergut-octopus commented 2 years ago

Team

Severity

Impacted one user so far, but could impact many. Workaround should be viable in most cases

Version

2022.1.2364, 2022.2.5111

Latest Version

I could reproduce the problem in the latest build

What happened?

If a 'Deployment Slot' is selected for an Azure Web App deployment target, it's impossible to reset to the default value (blank) via UI.

image

If a deployment slot is removed (so that only Production remains), I would expect to be able to reset this to default or be able to select the Production slot.

Reproduction

  1. Create a new Azure Web App and connect it as a deployment target in Octopus
  2. Add a deployment slot to the Web App in Azure (Web App > Deployment Slots > Add Slot)
  3. Set the Azure Web App Slot to the newly created one in Octopus and save
  4. Reload the page and attempt to update the slot
  5. Remove the slot in Azure, reload the page, and attempt to reset the slot

Slot will remain set to the one selected.

Error and Stacktrace

No response

More Information

Original issue - https://help.octopus.com/t/unable-to-remove-azure-web-app-slot-value/28037

Workaround

You can force the deployment slot to be reset via API call by changing the Machine.Endpoint.WebAppSlotName.

The following API script should perform this action. When running this script, be sure to read and fully understand it before doing so.

Substitute your own Octopus URL, API key, Space name, and Machine Id. Note the Machine ID can be found in the URL when in the Octopus Portal and viewing the machine under Infrastructure > Deployment Targets > (web app target)

# Define working variables
$octopusURL = "https://YOUR-OCTO-URL"
$octopusAPIKey = "API-####"
$header = @{ "X-Octopus-ApiKey" = $octopusAPIKey }
$spaceName = "YOUR-SPACE"
$machineId = "Machines-####"

# Get space
$space = (Invoke-RestMethod -Method Get -Uri "$octopusURL/api/spaces/all" -Headers $header) | Where-Object {$_.Name -eq $spaceName}

# Get machine
$machine = (Invoke-RestMethod -Method Get -Uri "$octopusURL/api/$($space.Id)/machines/$machineId" -Headers $header)

# Reset the Web App Slot
$machine.Endpoint.WebAppSlotName = ""

# Convert machine to JSON
$machine = $machine | ConvertTo-Json -Depth 100

# PUT the updated machine JSON with reset Web App Slot to the existing machine ID
Invoke-RestMethod -Method "Put" -Uri "$octopusURL/api/$($space.Id)/machines/$machineId" -Headers $header -Body ($machine)
SeanStanway-Octopus commented 2 years ago

Another customer experienced this: https://octopus.zendesk.com/agent/tickets/90764 (internal link)