Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ Lambda Runtime.
- `Getting started <#getting-started>`__
- `Advanced <#advanced>`__

- `Compiled Languages (Java) <#compiled-languages-java>`__
- `Compiled Languages <#compiled-languages>`__

- `Java <#compiled-languages-java>`__
- `.NET Core <#compiled-languages-dotnetcore>`__

- `IAM Credentials <#iam-credentials>`__
- `Lambda Environment
Variables <#lambda-environment-variables>`__
Expand Down Expand Up @@ -570,9 +574,11 @@ Getting started
Advanced
--------

Compiled Languages (Java)
Compiled Languages
~~~~~~~~~~~~~~~~~~~~~~~~~

**Java**

To use SAM CLI with compiled languages, such as Java that require a
packaged artifact (e.g. a JAR, or ZIP), you can specify the location of
the artifact with the ``AWS::Serverless::Function`` ``CodeUri`` property
Expand Down Expand Up @@ -611,6 +617,29 @@ file (or uber jar) containing all of the function dependencies.
You can find a full Java example in the `samples/java <samples/java>`__
folder

**.NET Core**

To use SAM Local with compiled languages, such as .NET Core that require a packaged artifact (e.g. a ZIP), you can specify the location of the artifact with the `AWS::Serverless::Function` `CodeUri` property in your SAM template.

For example:

```
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31

Resources:
ExampleJavaFunction:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When possible, mind changing to ExampleDotNetFunction?

Type: AWS::Serverless::Function
Properties:
Handler: HelloWorld::HelloWorld.Function::Handler
CodeUri: ./artifacts/HelloWorld.zip
Runtime: dotnetcore2.0
```

You should then build your ZIP file using your normal build process.

You can generate a .NET Core example by `sam init --runtime dotnetcore` folder.

.. _IAMCreds

IAM Credentials
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ This is a sample template for {{ cookiecutter.project_name }}
* AWS CLI already configured with at least PowerUser permission
* [Docker installed](https://www.docker.com/community-edition)
* [SAM Local installed](https://github.com/awslabs/aws-sam-cli)
* [DotNet Core installed](https://www.microsoft.com/net/download/macos)
* [DotNet Core installed](https://www.microsoft.com/net/download)

## Setup process

### Creating the project and its dependencies

In this example we use DotNet Core CLI to bundle our project with its dependencies:
### Linux & macOS

```bash
dotnet publish src/HelloWorld
sh build.sh --target=Package
```

### Windows (Powershell)

```powershell
build.ps1 --target=Package
```

### Local development
Expand Down Expand Up @@ -95,6 +99,21 @@ For testing our code, we use XUnit and you can use `dotnet test` to run tests de
```bash
dotnet test test/HelloWorld.Test
```

Alternatively, you can use Cake. It discovers and executes all the tests.

### Linux & macOS

```bash
sh build.sh --target=Test
```

### Windows (Powershell)

```powershell
build.ps1 --target=Test
```

# Appendix

## AWS CLI commands
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have been committed? Looks like a ide generated file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfuss in dotnet world the Solution file "glues" the projects. It is an artifact used to make it easy to restore NuGet packages or build the projects in one go. It is an abstraction created by Microsoft.
Started with Visual Studio, but if you use JetBrains Rider, it recognises and uses it.

When you are using Visual Studio Code you do not need it, since VS Code opens a folder.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O cool. Ya am not a .NET dev :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. Sharing is caring! ;)

Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{94965890-D3F6-4FF4-8EA1-73F73E89D19C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{D8B988DB-650C-4F45-9A9A-528F9E0CDDB7}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{68DF9E4E-E53E-4A13-8EDB-B63691A92CA9}"
ProjectSection(SolutionItems) = preProject
build.cake = build.cake
build.ps1 = build.ps1
build.sh = build.sh
template.yaml = template.yaml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{6DB7C3C2-84DC-4DD5-A070-8E3F186E184F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "src\HelloWorld\HelloWorld.csproj", "{9F62886F-73E6-4CBC-9A90-48BA8B56F13B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld.Tests", "test\HelloWorld.Test\HelloWorld.Tests.csproj", "{6B28DD0E-5B35-4F5A-943A-2C80953B7B3F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9F62886F-73E6-4CBC-9A90-48BA8B56F13B} = {94965890-D3F6-4FF4-8EA1-73F73E89D19C}
{6B28DD0E-5B35-4F5A-943A-2C80953B7B3F} = {6DB7C3C2-84DC-4DD5-A070-8E3F186E184F}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9F62886F-73E6-4CBC-9A90-48BA8B56F13B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9F62886F-73E6-4CBC-9A90-48BA8B56F13B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F62886F-73E6-4CBC-9A90-48BA8B56F13B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F62886F-73E6-4CBC-9A90-48BA8B56F13B}.Release|Any CPU.Build.0 = Release|Any CPU
{6B28DD0E-5B35-4F5A-943A-2C80953B7B3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B28DD0E-5B35-4F5A-943A-2C80953B7B3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B28DD0E-5B35-4F5A-943A-2C80953B7B3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B28DD0E-5B35-4F5A-943A-2C80953B7B3F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Loading