Azure appservice deployment does not clean root directory

DSenthil 20 Reputation points
2024-12-05T04:21:33.2933333+00:00

I am issuing below command to deploy to a Azure appservice in my Jenkins pipeline script. But I get below issues.

Command:

az webapp deploy --clean true --restart true --resource-group

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,212 questions
{count} votes

Accepted answer
  1. Shree Hima Bindu Maganti 2,415 Reputation points Microsoft Vendor
    2024-12-12T03:42:38.6766667+00:00

    Hi @DSenthil ,
    Thankyou for Your Response.
    As You mentioned DEPLOYMENT_TARGET works reliably and Subfolder deployments are successful when DEPLOYMENT_TARGET is set as an app setting.

    --target-path fails while Using --target-path directly results in an error ("Invalid directory name").

    1. Continue using DEPLOYMENT_TARGET for Subfolder Deployments.Set DEPLOYMENT_TARGET as an app setting before deployment.
    az webapp config appsettings set \
        --name <WEBAPP_NAME> \
        --resource-group <RESOURCE_GROUP> \
        --settings "DEPLOYMENT_TARGET=C:/home/site/wwwroot/<subfolder>"
    az webapp deploy \
        --resource-group <RESOURCE_GROUP> \
        --name <WEBAPP_NAME> \
        --src-path <SOURCE_ZIPFILE> \
        --clean true
    
    
    1. Update the DEPLOYMENT_TARGET dynamically in the pipeline before deployment.
         sh """
         az webapp config appsettings set \
         --name ${WEBAPP_NAME} \
         --resource-group ${RESOURCE_GROUP} \
         --settings "DEPLOYMENT_TARGET=${targetPath}"
         az webapp deploy \
         --resource-group ${RESOURCE_GROUP} \
         --name ${WEBAPP_NAME} \
         --src-path ${SOURCE_ZIPFILE} \
         --clean true
         """
         sh """ az webapp config appsettings set \     --name ${WEBAPP_NAME} \     --resource-group ${RESOURCE_GROUP} \     --settings "DEPLOYMENT_TARGET=${targetPath}" az webapp deploy \     --resource-group ${RESOURCE_GROUP} \     --name ${WEBAPP_NAME} \     --src-path ${SOURCE_ZIPFILE} \     --clean true """ 
      
      Avoid --target-path Until Resolved this parameter is unreliable; raise a GitHub issue with Azure CLI for further investigation.

    Azure App Service - Configure App Settings
    Azure Web App Deployment CLI Docs
    Azure Deployment Logs and Troubleshooting
    You can mark it 'Accept Answer' and 'Upvote' if this helped you

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. DSenthil 20 Reputation points
    2024-12-06T04:10:13.92+00:00

    If I use --async flag then I am not getting the 500 error. I am doing more testing

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.