3

I am building a very small Node/Express API app in Azure using Twilio to route communication for a small group. I initially built out a data structure for users in CosmosDB but found out it's minimum $24 per month, which is way over budget for something that will likely hold 20 or so records. Because of this, is seems much more reasonable to just build this into a json file that sits in a ./json subfolder. However, it has occurred to me that whenever I deploy, I would be overwriting this file with the default file I have locally. I have been working via the Azure App Service tool in Visual Studio Code and can't figure out a way to make it ignore the file.

I can go into Kudu and copy the file down each time before I deploy, but I will eventually forget and this sounds like a very brittle process.

I added a json/ line to .gitignore, but that has no effect on the deployment (as expected).

I also added "appService.zipIgnorePattern": ["json{,/**}"] to the settings.json file, but instead of just ignoring that folder on the server, it erases it on deploy (the zip ignores it and then it wipes/replaces the whole wwwsite folder). Looking for the file gives me {"Message":"'D:\\home\\site\\wwwroot\\json\\users.json' not found."}

I was hoping there is a setting that would deploy, replacing all folders in the package, and ignoring all content in the ./json folder. Does this exist?

2 Answers2

1

Alternative solution, 2021:

Instead of excluding folders, select the folder that you do want to deploy. Data in other folders will not be affected.

Deploy from: edit .vscode/settings.json in your local project and add "appService.deploySubpath": "./folderToDeploy"

Deploy to: In the Azure Portal go to your app service. Under Configuration / Application Settings add a new Application Setting with name SCM_TARGET_PATH and value ./folderToDeployTo

g.kertesz
  • 434
  • 3
  • 10
0

Using VS Code right+click deploy will deploy the contents of the folder. I was able to work around this by adding Azure as a remote branch and using .gitignore. I placed my json file inside a random folder (content/json) then placed /content/json in my .gitignore file.

enter image description here

enter image description here

Ryan Hill
  • 1,821
  • 2
  • 8
  • 21
  • I'm struggling here, because I added it to the ignore, then did `git rm --cached ` on the files, then pushed via git, and it is just wiping out the folder in Azure. Is there another step, or something I'm misunderstanding about git? – Tristan Markwell May 30 '19 at 16:43
  • And you add Azure a remote got source? – Ryan Hill May 30 '19 at 23:31
  • I have to see if there's an option to keep destination files when doing a git push to the remote. If it turns out there isn't, one short term measure you can do is store your json file in either blob storage or table storage. Both storage solutions are a little cheaper than cosmos and will for your scenario just fine. – Ryan Hill May 30 '19 at 23:34