aws / aws-extensions-for-dotnet-cli

Extensions to the dotnet CLI to simplify the process of building and publishing .NET Core applications to AWS services
Apache License 2.0
369 stars 86 forks source link

How Do You "dotnet lambda package-ci" for arm64? #228

Closed hounddog22030 closed 1 year ago

hounddog22030 commented 2 years ago

Describe the issue

We are trying to use dotnet lambda package-ci to package for arm64

dotnet lambda package --help documentation shows -farch | --function-architecture The architecture of the Lambda function. Valid values: x86_64 or arm64. Default is x86_64

Yet, dotnet lambda package-ci --help shows no switch for architecture.

We have issued:

  1. dotnet lambda package-ci ... --runtime linux-arm64
  2. dotnet lambda package-ci ... --function-architecture arm64 --msbuild-parameters "--arch linux-arm64"
  3. dotnet lambda package-ci ... --function-architecture arm64

These do not produce any arm64 results, all produce the publish command as something like dotnet publish --output "/codebuild/output/src054284391/src/bbapi/WebApi/./bin/Release/net6.0/publish" --configuration "Release" --framework "net6.0" /p:GenerateRuntimeConfigurationFiles=true --runtime linux-x64 --self-contained false or an error

Links

https://github.com/aws/aws-extensions-for-dotnet-cli

ashishdhingra commented 2 years ago

Hi @hounddog22030,

Good morning.

Thanks for reporting the issue. Upon investigating further:

For dotnet lambda package-ci command, the workaround is to specify --msbuild-parameters with value --runtime linux-arm64. In other words, the command would look like dotnet lambda package-ci ... --msbuild-parameters "--runtime linux-arm64". Please let me know if it works for you.

Thanks, Ashish

hounddog22030 commented 2 years ago

Please let me know if it works for you.<<

Yep. Thanks! Do you want me to do a PR to add that to the documentation?

ashishdhingra commented 2 years ago

Please let me know if it works for you.<<

Yep. Thanks! Do you want me to do a PR to add that to the documentation?

@hounddog22030 I don't think this workaround should be a part documentation update. This should instead be discussed with team on the missing --function-architecture for dotnet lambda package-ci command. I would label this is a bug so that it could be discussed with the team.

normj commented 2 years ago

@hounddog22030 For the package-ci command the tool uses the CloudFormation to determine what architecture to package the function for. So if you want to use ARM then set the Architectures property on the function.

    "Get": {
      "Type": "AWS::Serverless::Function",
      "Properties": {
        "Handler": "AWSServerless96::AWSServerless96.Functions::Get",
        "Runtime": "dotnet6",
        "Architectures" : ["arm64"],
        "CodeUri": "",
        "MemorySize": 256,
        "Timeout": 30,
        "Role": null,
        "Policies": [
          "AWSLambdaBasicExecutionRole"
        ],
        "Events": {
          "RootGet": {
            "Type": "Api",
            "Properties": {
              "Path": "/",
              "Method": "GET"
            }
          }
        }
      }
    }
ashishdhingra commented 2 years ago

Thanks @normj for the inputs.

@hounddog22030 Please refer existing example template https://github.com/aws/aws-extensions-for-dotnet-cli/blob/master/testapps/TestServerlessWebApp/serverless-arm.template as reference. If this helps, kindly confirm if this issue could be closed.

hounddog22030 commented 2 years ago

@hounddog22030 For the package-ci command the tool uses the CloudFormation to determine what architecture to package the function for. So if you want to use ARM then set the Architectures property on the function.

    "Get": {
      "Type": "AWS::Serverless::Function",
      "Properties": {
        "Handler": "AWSServerless96::AWSServerless96.Functions::Get",
        "Runtime": "dotnet6",
        "Architectures" : ["arm64"],
        "CodeUri": "",
        "MemorySize": 256,
        "Timeout": 30,
        "Role": null,
        "Policies": [
          "AWSLambdaBasicExecutionRole"
        ],
        "Events": {
          "RootGet": {
            "Type": "Api",
            "Properties": {
              "Path": "/",
              "Method": "GET"
            }
          }
        }
      }
    }

I have confirmed this is as @normj describes. Didn't see that coming ;-) Do you want me to do a PR to document that?

normj commented 2 years ago

@hounddog22030 I think a doc PR makes sense. I assume we are talking on the README. Also I realized the help on dotnet lambda package-ci --help is pretty bad. If you want to make PR to improve it that would be great https://github.com/aws/aws-extensions-for-dotnet-cli/blob/master/src/Amazon.Lambda.Tools/Commands/PackageCICommand.cs#L15

hounddog22030 commented 2 years ago

PR: https://github.com/aws/aws-extensions-for-dotnet-cli/pull/229

I didn't dive into https://github.com/aws/aws-extensions-for-dotnet-cli/blob/master/src/Amazon.Lambda.Tools/Commands/PackageCICommand.cs#L15 (yet)

ashishdhingra commented 2 years ago

PR: #229

I didn't dive into https://github.com/aws/aws-extensions-for-dotnet-cli/blob/master/src/Amazon.Lambda.Tools/Commands/PackageCICommand.cs#L15 (yet)

@hounddog22030 Somehow I do not see any concrete changes in the PR https://github.com/aws/aws-extensions-for-dotnet-cli/pull/229.

hounddog22030 commented 2 years ago

I think a doc PR makes sense

Per @normj, I did a "doc PR". Do you not see

PR: #229 I didn't dive into https://github.com/aws/aws-extensions-for-dotnet-cli/blob/master/src/Amazon.Lambda.Tools/Commands/PackageCICommand.cs#L15 (yet)

@hounddog22030 Somehow I do not see any concrete changes in the PR #229.

Sorry, I think the push failed. Please check again, I've pushed and verified it's there now.

normj commented 1 year ago

Thanks for the doc PR @hounddog22030. I have merged in the changes.

github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.