Azure / Azure/azure-powershell

Publish-AzWebApp always cleans web app files, irrespective of -Clean option

Open
#24,234 9 comments 0 reactions 0 assignees View on GitHub
act-observability-squad App Services bug customer-reported Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

### Description

Publish-AzWebApp has a Clean option, described as follows: Cleans the target directory prior to deploying the file(s).

However, when I run Publish-AzWebApp, it always cleans the /site/wwwroot on the web app (both files and directories). This irrespective of whether -Clean is used. Also irrespective of whether -TargetPath is used.

This makes it impossible to use Publish-AzWebApp to copy my web site to the web app using several calls to Publish-AzWebApp. This is critical, because 1) my web site has over 6GB of files; 2) our developers need to be able to update part of the site while leaving other parts alone.

It is treacherous too - if you use Publish-AzWebApp without -Clean, you can expect it to not clean /site/wwwroot, while it does without even an error message.

### Issue script & Debug output

```PowerShell
I ran the lines below in Powershell 7, and verified the outcome in the web app using an FTP client.
Not sure what you mean with a "debug stream"

# Set up the test. copies productionadmin to dir /site/wwwroot/k in the web app
Publish-AzWebApp -ResourceGroupName $rg -Name $site -ArchivePath productionadmin.zip -TargetPath k

# copies productionadmin to dir /site/wwwroot/y in the web app. k has been removed
Publish-AzWebApp -ResourceGroupName $rg -Name $site -ArchivePath productionadmin.zip -TargetPath y

# copies productionadmin to dir /site/wwwroot/x in the web app. y has been removed
Publish-AzWebApp -ResourceGroupName $rg -Name $site -ArchivePath productionadmin.zip -TargetPath x -Clean:$false

# copies productionadmin to dir /site/wwwroot/z in the web app. x has been removed
Publish-AzWebApp -ResourceGroupName $rg -Name $site -ArchivePath productionadmin.zip -TargetPath z -Clean:0

# runs without error messages. but sowadmin is not copied to the web app at all. z is still there
Publish-AzWebApp -ResourceGroupName $rg -Name $site -ArchivePath sowadmin.zip -TargetPath /site/wwwroot/b

# copies sowadmin to /site/wwwroot. but z has been removed
Publish-AzWebApp -ResourceGroupName $rg -Name $site -ArchivePath sowadmin.zip
```

### Environment data

```PowerShell
Name Value
---- -----
PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```

### Module versions

```PowerShell
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.15.1 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzConte…
Script 3.2.0 Az.Websites {Add-AzWebAppAccessRestrictionRule, Add-AzWebAppT…
```

### Error output

```PowerShell
There is no error output. Publish-AzWebApp seems to work fine.
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the listed Publish-AzWebApp calls with different TargetPath and Clean values, then trace the Publish-AzWebApp implementation and its handling of those parameters. Done means deployments preserve existing /site/wwwroot content unless -Clean is explicitly enabled, while each specified target path receives its archive.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.