Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
412 stars 202 forks source link

package: support ignore files #4381

Open weikanglim opened 1 month ago

weikanglim commented 1 month ago

As authored by @jongio based on #4258. Related to #1039 , #4215

Background

We currently support .dockerignore files when uploading source for remote docker builds. This feature enhancement tracks addition of ignore files for other packaging protocols.

Work In-scope

@jongio had gotten agreements from service teams to add support for .webappignore and .funcignore files. These files are interpreted as standard .gitignore syntax. When present, these ignore files should be read as configuration to exclude files. The exclusion files apply relatively to the directory which the ignore file is present. Additional details of the implementation are specified below:

Default behavior when ignore files not present

With SCM_DO_BUILD_DURING_DEPLOYMENT=true (for app service), remoteBuild=true (for func-flex-consumption), users would not expect the following directories to be packaged:

Thus, we should continue applying these default exclusion behaviors when ignore files are not present.

For function apps, local.settings.json is a local configuration file that should not be expected to be published by default. We should take this into account as well. This isn't backwards compatible -- but is the right thing to do since it has been a missing user-requested feature of azd.

Explorations

  1. Should the ignore logic differ based on SCM_DO_BUILD_DURING_DEPLOYMENT? See comment here
  2. What is the function tools team plan to address the non-standard interpretation of .funcignore? https://github.com/Azure/azure-functions-core-tools/issues/2701
  3. Should we support ignore files in subdirectories? What are good use cases for this?
pamelafox commented 1 month ago

One use case for .webappignore:

We would like to support developers using NSGs in their VNet with Azure App Service. That's not currently possible since App Service build uses Oryx which calls out to a Oryx server that doesn't have a static IP address. If we could do the build locally, then we could disable the Oryx build, and be able to use NSGs. If we try that now, our venv won't be uploaded, since your default behavior is to ignore any folders that resemble Python virtual environments. So we need webappignore so we can get azd to not ignore folders.

Another use case:

We are supporting both ACA and App Service in our repo now. If we had a .webapp ignore, we could avoid uploading the Dockerfile to App Service. Not a huge deal since that's a tiny file.

One more use case:

Many devs write their tests/ folder inside the src/ folder, due to the difficulties with having tests/ outside of src/. Ideally those tests would not get uploaded to App Service.