PrimroseBank
PrimroseBank

Reputation: 41

Deploying static file to Azure App Service using Azure CLI

I'm trying to deploy a single file to an Azure App Service website using the Azure cli command as below:

    az webapp deploy --resource-group <group-name> --name <app-name> --src-path config.json --type=static

But when I run it I get an error stating:

    ERROR: An error occured during deployment. Status Code: 400, Details: "Path must be defined for type='Static'"

So then I define a path and get:

    ERROR: unrecognized arguments: --path=/home/site/wwwroot/xxx.json

I'm assuming this is because my website is not static. I just want to deploy a single file from a known location in DevOps to the root directory on the website.

Any ideas how to solve this? thank you.

Upvotes: 4

Views: 2266

Answers (2)

Bowman Zhu
Bowman Zhu

Reputation: 7146

Venkatesan's answer is correct.

Your understanding of 'Static' is not correct.

See this official document:

https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Web-App:-Configuration-Details#resource

So no need type.

On my side I just run two commands:

@{} | ConvertTo-Json | Out-File "xxx.json"

az webapp deploy --resource-group xxx --name xxx --src-path xxx.json --target-path site/wwwroot/xxx.json

It works:

enter image description here

If you only need to change one time and your app service, directly move the file with mouse is a possible way.

You can also use FTP method for automatic changing.

Upvotes: 0

Venkatesan
Venkatesan

Reputation: 10292

I tried in my environment and got below results:

Initially I tried same commands to deploy a single file to an Azure App Service and got similar error.

Commands:

   az webapp deploy --resource-group <group-name> --name <app-name> --src-path config.json --type=static

Console:

enter image description here

According to this Ms-Docs we need to deploy a file with source path and target path.

Commands:

az webapp deploy --resource-group ResouceGroup --name AppName --src-path SourcePath --type static --target-path staticfiles/test.txt

I tried the above command which can deploy a file to azure app service.

Console:

enter image description here

Portal:

You can check the deployments in the portal by App-service -> advanced tools -> go -> Debug console ->path which you have stored.

enter image description here

Upvotes: 4

Related Questions