Hi @MoTaar
You can use the Azure App Services Backup/Restore to backup your site as zip files
https://learn.microsoft.com/en-us/azure/app-service/manage-backup?WT.mc_id=AZ-MVP-5004665
If you still need to use the script, then you can use something like the below:
# Ensure you have the Azure PowerShell module installed and imported
Import-Module Az
# Variables
$resourceGroupName = "<YourResourceGroupName>"
$webAppName = "<YourWebAppName>"
$zipFileName = "$webAppName-$(Get-Date -Format 'yyyyMMddHHmm').zip"
$destinationPath = "<YourLocalBackupPath>\" + $zipFileName
# Authenticate with Azure if not already logged in
# Connect-AzAccount
# Get the publishing profile for the Azure Web App
$publishingProfile = Get-AzWebAppPublishingProfile -ResourceGroupName $resourceGroupName -Name $webAppName
# Extracting deployment credentials from the publishing profile
$username = $publishingProfile.Properties.PublishingUserName
$password = $publishingProfile.Properties.PublishingPassword
# Define the base64 authorization for the header
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
# Define the Kudu API zip endpoint
$apiUrl = "https://$webAppName.scm.azurewebsites.net/api/zip/site/wwwroot/"
# Make the web request to the Kudu API to get the zip file
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method GET -OutFile $destinationPath
Write-Host "Backup of $webAppName completed successfully. File saved to $destinationPath"