When running in Sitecore Managed Cloud PaaS, the following is how the paths are defined:
<filePaths hint="list">
<filePath>D:\home\site\wwwroot\App_Data/items/$(id)</filePath>
<modulesFilePath>/sitecore modules/items/$(id)</modulesFilePath>
</filePaths>
Instead, you should test if the path is absolute, and if that is the case, don't try and map it, but just use it as-is.
One way to test for it might be to test for a colon, since that would only be there in case of an absolute filesystem path.
Write-Host "path in config $filepath"
if ($filepath -like "*:*") {
$serverpath = $filepath
} else {
$serverpath = [Sitecore.IO.FileUtil]::MapPath("~/$filepath")
}
Write-Host "ServerPath = $serverpath"
The above is tested, and solves the issue.