Npgsql 3.1.9๋ฅผ ์ฌ์ฉ ์ค์ด์์ต๋๋ค.
START RequestId: 147aefc2-c10f-11e6-b24b-6daefcf72be1 Version: $LATEST
Exception System.TypeInitializationException: The type initializer for 'Npgsql.TypeHandlerRegistry' threw an exception. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.Assembly.GetTypes()
at Npgsql.TypeHandlerRegistry..cctor()
--- End of inner exception stack trace ---
at Npgsql.TypeHandlerRegistry.Setup(NpgsqlConnector connector, NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout)
at Npgsql.ConnectorPool.Allocate(NpgsqlConnection conn, NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnection.OpenInternal()
at Seaside.Api.HelloWorld.Functions.<GetAsync>d__0.MoveNext()
END RequestId: 147aefc2-c10f-11e6-b24b-6daefcf72be1
REPORT RequestId: 147aefc2-c10f-11e6-b24b-6daefcf72be1 Duration: 96.22 ms Billed Duration: 100 ms Memory Size: 256 MB Max Memory Used: 31 MB
๋ค์ดํฐ๋ธ ์ข ์์ฑ์ ํด๊ฒฐํ๋ ๊ฒ์ ์ฐ๋ฆฌ๊ฐ ๊ฐ์ ํ๊ธฐ ์ํด ๋ ธ๋ ฅํ๊ณ ์๋ ๊ฒ์ ๋๋ค. ๊ทธ๋๊น์ง ํด๊ฒฐ ๋ฐฉ๋ฒ์ผ๋ก aws-lambda-tools-defaults.json ํ์ผ์ ๊ธฐ๋ณธ ํ์ธ์ ๊ฐ์ ์คํํ๋ "additional-files" ์์ฑ์ ์ถ๊ฐํ ์ ์์ต๋๋ค. ์ด ์์ ์ ์ํํ๋ฉด postgresql ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค.
...
"function-handler": "NpgsqlTest::NpgsqlTest.Function::FunctionHandler",
"additional-files": [
"runtimes/linux/lib/netstandard1.3/System.Net.NetworkInformation.dll"
]
}
๋์ค ์ ๋ ๐
๋์ผํ ๋ฌธ์ ๊ฐ ์์ง๋ง Mac์ .Net ์ฝ์ด๋ฅผ ์ฌ์ฉํฉ๋๋ค. Visual Studio ๋๋ aws-lambda-tools๋ฅผ ์ฌ์ฉํ์ง ์์ ๋ "์ถ๊ฐ ํ์ผ"์ ํด๋นํ๋ ๊ฒ์ด ์์ต๋๊น?
Amazon.Lambda.Tools NuGet ํจํค์ง๋ฅผ ์ฌ์ฉํ์ฌ ๋ฐฐํฌํ๋ ๊ฒฝ์ฐ lambda deploy-function ์ ์คํํ ๋ Visual Studio์์ ์ถ๊ฐ ํ์ผ ์น์ ์ ํฌํจํ๋ ๊ฒ์ฒ๋ผ aws-lambda-tools-defaults.json ํ์ผ์ ์ฝ์ต๋๋ค.
Mac ์ฌ์ฉ์๋ฅผ ์ง์ํ๊ธฐ ์ํด Visual Studio์ ๋ชจ๋ ๋ฐฐํฌ ๊ธฐ๋ฅ์ dotnet CLI๋ฅผ ํตํด ์ฌ์ฉํ ์ ์๋๋ก ํ๊ณ ์ถ์์ต๋๋ค.
์ด ๋ต๋ณ์ ์ ์๊ฒ ํจ์ฌ ๋ ๋ง์ ๊ณ ํต์ ๋์ด์ฃผ์์ต๋๋ค ... ๊ทธ๋ฌ๋ VS๋ฅผ ์ฌ์ฉํ์ฌ ํจํค์ง/์ ๋ก๋๋ฅผ ๋น๋ํ์ง ์๊ณ ๋์ ์ผ๋ฐ coreclr ๋๊ตฌ(์: "dotnet publish"), aws-lambda-tools- defaults.json์ ๋ฌด์๋๋ฏ๋ก ์ด ํ์ผ์ ํจํค์ง ๋๋ ํ ๋ฆฌ์ ๋ฃจํธ์ ์๋์ผ๋ก ๋ณต์ฌํด์ผ ํฉ๋๋ค.
dotnet publish
์ฌ์ฉํ๋ ๋์ dotnet lambda package
์ ์ฌ์ฉํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด Visual Studio์์ ์ํํ๋ ๊ฒ๊ณผ ๋์ผํ ํจํค์ง์ ์ํํ์ง๋ง dotnet CLI์์ ์ํํฉ๋๋ค. ๋น์ ์ ํจํค์ง ์ฐ๋ฆฌ๋ NuGet์ ํตํด DOTNET์ CLI์ ์ถ๊ฐ ํ ๋ช
๋ น์ ์ ์ฒด ๋ชฉ๋ก์ ๋ณผ ์ ์์ต๋๋ค Amazon.Lambda.Tools
์คํํ์ฌ dotnet lambda help
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋ค์ดํฐ๋ธ ์ข ์์ฑ์ ํด๊ฒฐํ๋ ๊ฒ์ ์ฐ๋ฆฌ๊ฐ ๊ฐ์ ํ๊ธฐ ์ํด ๋ ธ๋ ฅํ๊ณ ์๋ ๊ฒ์ ๋๋ค. ๊ทธ๋๊น์ง ํด๊ฒฐ ๋ฐฉ๋ฒ์ผ๋ก aws-lambda-tools-defaults.json ํ์ผ์ ๊ธฐ๋ณธ ํ์ธ์ ๊ฐ์ ์คํํ๋ "additional-files" ์์ฑ์ ์ถ๊ฐํ ์ ์์ต๋๋ค. ์ด ์์ ์ ์ํํ๋ฉด postgresql ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค.