Azure kudu vfs API 不支持其中包含“#”的文件名

Azure kudu vfs API does not support files names having "# " in them

我正在使用 kudu vfs API 在两个 Azure 网站之间同步两个文件夹。为此,我正在从第一个网站下载不在第二个网站中的文件,并将它们上传到第二个网站。

下载文件:

 Invoke-RestMethod -Uri $kuduApiUrl `
                    -Headers @{"Authorization"=$kuduApiAuthorisationToken;"If-Match"="*"} `
                    -Method GET `
                    -OutFile $localPath `
                    -ContentType "multipart/form-data"

上传文件:

 $result = Invoke-RestMethod -Uri $kuduApiUrl `
                    -Headers @{"Authorization"=$kuduApiAuthorisationToken;"If-Match"="*"} `
                    -Method PUT `
                    -InFile $localPath `
                    -ContentType "multipart/form-data"

如果文件名不包含 #,一切正常。失败案例: $kuduApiUrl = "https://targetWebAppName.scm.azurewebsites.net/api/vfs/site/wwwroot/Content/Uploads/09.01#Import Listabc.txt"

$kuduApiUrl = "https://targetWebAppName.scm.azurewebsites.net/api/vfs/site/wwwroot/Content/Uploads/#09.01Import Listabc.txt"

因为#是URI中的转义字符,只需将#换成%23即可。