azure-functions-core-tools icon indicating copy to clipboard operation
azure-functions-core-tools copied to clipboard

.funcignore does not support wildcards

Open coderbyheart opened this issue 4 years ago • 5 comments

Adding a wildcard to the .funcignore has no effect.

cat .funcignore 
*.ts

func -v
3.0.3568

func azure functionapp publish myapi --list-included-files | grep .ts | wc
  10968   10968 1061578

coderbyheart avatar Sep 02 '21 09:09 coderbyheart

According to https://github.com/Azure/azure-functions-core-tools/blob/db2ff784941c3f6241aea996818ba370ea441bd2/src/Azure.Functions.Cli/Common/GitIgnoreParser.cs#L8 the ignore parser is a C# reimplementation of the basically dead https://github.com/codemix/gitignore-parser which has several logic flaws and isn't compliant with the git ignore spec - see the issue tracker for that project for some of the problems and note how long ago the most recent commit is.

I recommend removing the DIY parser in favor of https://github.com/goelhardik/ignore or similar to gain full gitignore syntax compliance and less maintenance headaches.

kf6kjg avatar Aug 27 '22 01:08 kf6kjg

Short term bandaid hack workaround found using BASH/ZSH.

  1. Move your .funcignore to .funcignore.source.
  2. Add .funcignore to your .gitignore.
  3. Add the following to your package.json as a custom deploy command, or add as a script call in whatever tooling you use:
deploy() {
  rm -f .funcignore
  npm run build \
  && git ls-files --cached --others --ignored --exclude-from=.funcignore.source > .funcignore \
  && echo '.funcignore' >> .funcignore \
  && func azure functionapp publish "$@" --typescript;
}
  1. Commit the above changes. You want to make sure that your git history shows that the file has been moved since you don't want to commit the compiled edition the above script creates.
  2. Call the deploy script passing the name of your Function app.

Note that user of other languages would need to modify the above, but the user of this hack should be able to work out how to integrate it.

kf6kjg avatar Dec 22 '22 22:12 kf6kjg

Is .funcignore supported syntax included in the web documentation somewhere? Couldn't find it.

th0ger avatar Aug 15 '23 23:08 th0ger

@th0ger I cannot either. That said the code itself appears to be designed with the intention of using gitignore syntax, and this is supported by the posts around the introduction of the feature and the commit message that introduced it. https://github.com/Azure/azure-functions-core-tools/issues/341#issuecomment-364310826

Additionally the default funcignore file generated by the cli uses globs in gitignore style - globs that do not work at the moment.

kf6kjg avatar Aug 15 '23 23:08 kf6kjg

Since this seems to be a bigger issue and will take a while to fix, should we maybe update the cli to generate files that will actually work in the meantime and add a warning to the documentation?

jp-hoehmann avatar Mar 14 '24 20:03 jp-hoehmann