Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure-functions-core-tools templates are missing from 24.05 package #317497

Open
beforan opened this issue Jun 5, 2024 · 2 comments
Open

azure-functions-core-tools templates are missing from 24.05 package #317497

beforan opened this issue Jun 5, 2024 · 2 comments
Labels
0.kind: bug Something is broken

Comments

@beforan
Copy link

beforan commented Jun 5, 2024

Quick heads up: I'm pretty brand new to Nix, so apologies if I've missed something or if I go about this issue the wrong way. Let me know.

Describe the bug

Installing the current release (24.05) or unstable (at time of writing) package of azure-functions-core-tools (package version 4.0.5455) leaves some functionality unusable due to the templates/ directory of the release missing from the nix cache.

I've tried to init a new .NET function and the tools cannot complete due to the missing templates:

[user@system:~]$ func init FunctionApp --worker-runtime dotnet-isolated --target-framework net8.0

Can't find templates location. Looked under '/nix/store/0ydxfg1b4r6f2ylbbd80x1s2i91w7v5k-azure-functions-core-tools-4.0.5455/lib/azure-functions-core-tools/templates/net-isolated'

Sure enough, if I cd to that location, the whole templates/ directory is not present.

Here is the GitHub release the 24.05 package should presumably be pulling (based on the package version):
https://github.com/Azure/azure-functions-core-tools/releases/tag/4.0.5455

Downloading an asset from the above and unzipping it does contain the templates/ directory as expected.

Switching to 23.11 and using azure-functions-core-tools version 4.0.5348 works correctly.

I've observed this using Flakes and nix develop / direnv on both Fedora 40 with Nix and macOS using nix-darwin.

Steps To Reproduce

Steps to reproduce the behavior:

  1. create a Flake targeting nixpkgs unstable or 24.05
  2. define a devShell with the following packages:
    • azure-cli
    • azure-functions-core-tools
  3. Define combined dotnet packages per these docs:
    (with dotnetCorePackages;
          combinePackages [
            sdk_8_0 # SDK for the app itself

            # .NET 6 for func tools
            runtime_6_0
            aspnetcore_6_0
          ])
  1. nix develop
  2. try to init a new dotnet Function App:
    • func init FunctionApp --worker-runtime dotnet-isolated --target-framework net8.0
  3. Get the error described above.
Example Flake to reproduce
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
  };

  outputs = {
    self,
    nixpkgs,
    ...
  } @ inputs: let
    forEachSystem = nixpkgs.lib.genAttrs ["aarch64-darwin" "x86_64-linux"];
  in {
    devShells =
      forEachSystem
      (system: let
        pkgs = nixpkgs.legacyPackages.${system};
      in {
        default = pkgs.mkShell {
          name = "my-project-shell";

          packages = with pkgs; [
            (with dotnetCorePackages;
              combinePackages [
                sdk_8_0
                runtime_6_0
                aspnetcore_6_0
              ])
            azure-cli
            azure-functions-core-tools
          ];
        };
      });
  };
}

Expected behavior

func init FunctionApp --worker-runtime dotnet-isolated --target-framework net8.0

should successfully complete and create a new Function App.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

I don't know if this affects anything other than dotnet - not familiar enough with the inner working of the azure functions tools to know what else uses that templates directory.

I have confirmed it works with the 23.11 version for azure-functions-core-tools: Here's a Flake that works for me:

Example Flake with workaround
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    func-nixpkgs.url = "github:NixOS/nixpkgs?ref=release-23.11";
  };

  outputs = {
    self,
    nixpkgs,
    func-nixpkgs,
    ...
  } @ inputs: let
    forEachSystem = nixpkgs.lib.genAttrs ["aarch64-darwin" "x86_64-linux"];
  in {
    devShells =
      forEachSystem
      (system: let
        pkgs = nixpkgs.legacyPackages.${system};
        func-pkgs = func-nixpkgs.legacyPackages.${system};
      in {
        default = pkgs.mkShell {
          name = "my-project-shell";

          packages = with pkgs; [
            (with dotnetCorePackages;
              combinePackages [
                sdk_8_0
                runtime_6_0
                aspnetcore_6_0
              ])
            azure-cli
            func-pkgs.azure-functions-core-tools
          ];
        };
      });
  };
}

Since the 23.11 version works, I have noticed that the package scripts differ quite a lot between 23.11 and 24.05.

I'm not deep enough into Nix yet to know if the difference matters, but clearly they are approaching the packaging a little differently.

Notify maintainers

@mdarocha @Detegr are package maintainers
@momeemt has opened #310237 to upgrade the tools but it still uses the 24.05 package approach; would be interested to know if that has the same issue.

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
this path will be fetched (0.00 MiB download, 0.00 MiB unpacked):
  /nix/store/y11cs26gb9b1irv5hk776mra7hgy80bl-nix-info
copying path '/nix/store/y11cs26gb9b1irv5hk776mra7hgy80bl-nix-info' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 6.8.10-301.fsync.fc40.x86_64, Fedora Linux, 40.20240531.0 (Kinoite), nobuild`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/nix/store/fjs1x9gz2n1dvjqcyyl6qsw110qxc2zn-source`

Add a 👍 reaction to issues you find important.

@beforan beforan added the 0.kind: bug Something is broken label Jun 5, 2024
@doggy8088
Copy link

Any workaround?

@Andreas02-dev
Copy link

@beforan Thanks for bringing this to our attention.
Looking at the packaging difference between 23.11 and 24.05, it's clear why this happens.

In 23.11, we fetch the zip (which includes the templates, as you have already found out) and patch the executables to work for NixOS.
In 24.05, we have opted for a different approach which is to compile the executables using the builder modules in nixpkgs, so there is no need for patching.

It seems that in switching packaging approaches, we have missed that some files (such as the templates directory) should also be present in the derivation.
@momeemt, since you have already created a PR for the updated version of the azure-functions-core-tools, would you be open to fixing this in your PR by adding the templates folder in the postInstall phase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants