{"id":9739,"date":"2019-02-26T12:34:00","date_gmt":"2019-02-26T03:34:00","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/?p=9739"},"modified":"2019-02-26T12:53:43","modified_gmt":"2019-02-26T03:53:43","slug":"azure-functions%e3%81%aedocker%e7%89%88%e3%82%92%e3%83%ad%e3%83%bc%e3%82%ab%e3%83%ab%e3%81%a7%e8%b5%b7%e5%8b%95%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/9739","title":{"rendered":"Azure Functions\u306eDocker\u7248\u3092\u30ed\u30fc\u30ab\u30eb\u3067\u8d77\u52d5\u3059\u308b"},"content":{"rendered":"<p>Azure Functions \u3067\u300c\u306a\u3067\u3057\u3053\u300d\u304c\u52d5\u304f\u3068\u304b\u300cCOBOL\u300d\u304c\u52d5\u304f\u3068\u304b\u3068\u3044\u3046\u8a18\u4e8b\u304c\u3042\u3063\u305f\u30cf\u30ba\u306a\u306e\u3060\u304c\u3001\u3053\u308c\u96e3\u3057\u3044\u306e\u3067\u306f\uff1f\u3068\u306f\u601d\u3063\u3066\u3044\u305f\u304c\u3001\u5b9f\u306f\u5185\u90e8\u3067 Docker \u304c\u52d5\u3044\u3066\u3044\u308b\u3060\u3051\u3060\u3063\u305f\u3001\u3068\u3044\u3046\u8a71\u3002<\/p>\n<p>Azure \u3067\u30b5\u30fc\u30d0\u30fc\u30ec\u30b9\u306aFunction App\u3092\u4f5c\u308b\u3068\u304d\u306b\u3001\u73fe\u72b6\u3067\u306fWindows\u74b0\u5883\u306b\u3059\u308b\u3068\u300cdotnet\u300d\u3068\u300cnode\u300d\u3001\u300cjava\u300d\u304c\u9078\u3079\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3002\u305d\u308c\u305e\u308c VM \u74b0\u5883\u3092 Azure \u5074\u3067\u7528\u610f\u3057\u3066\u305d\u308c\u306e\u4e0a\u3067\u52d5\u304b\u3059\u306e\u3060\u304b\u3089\u3001\u3053\u306e\u3042\u305f\u308a\u306e\u74b0\u5883\u306f Azure = Microsoft \u793e\u304c\u7528\u610f\u3059\u308b\u3093\u3060\u308d\u3046\u306a\u3041\u3068\u3044\u3046\u306e\u304c\u60f3\u50cf\u3067\u304d\u308b\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2019\/02\/image-12.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2019\/02\/image_thumb-12.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"383\" height=\"326\" style=\"margin: 0px; border: 0px currentcolor; display: inline; background-image: none;\"><\/a><\/p>\n<p>\u3082\u3046\u3072\u3068\u3064\u3001Linux \u74b0\u5883\u3068\u3044\u3046\u306e\u304c\u3042\u3063\u3066\u3001\u3053\u3063\u3061\u306f .NET \u3068 JavaScript \u3068 python \u304c\u9078\u3079\u308b\u3002Windows \u306e\u307b\u3046\u306b python \u306e\u304c\u306a\u3044\u306e\u306f\u4f55\u6545\uff1f\u3068\u304b PHP \u306f\u4f55\u51e6\u3067\u52d5\u304b\u3059\u306e\u304b\uff1f\u3068\u4e0d\u601d\u8b70\u306b\u601d\u3063\u3066\u3044\u305f\u306e\u3060\u304c\u3001\u5b9f\u306f PHP \u306e\u3088\u3046\u306a\u307b\u304b\u306e\u8a00\u8a9e\u306f\u3001Linux \u74b0\u5883\u3067\u306e\u300cDocker \u30a4\u30e1\u30fc\u30b8\u300d\u306e\u307b\u3046\u306b\u4f5c\u308b\u3053\u3068\u306b\u306a\u308b\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2019\/02\/image-13.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2019\/02\/image_thumb-13.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"384\" height=\"373\" style=\"margin: 0px; border: 0px currentcolor; display: inline; background-image: none;\"><\/a><\/p>\n<p>Function App \u306f\u5185\u90e8\u7684\u306b\u306f App Service \u3068\u540c\u3058\u306a\u306e\u3067\u3001\u3064\u307e\u308a\u306f VM \u4e0a\u3067\u52d5\u3044\u3066\u3044\u308b\u3002App Service \u306e\u307b\u3046\u306f\u3001HTTP \u30d7\u30ed\u30c8\u30b3\u30eb\u306e\u53d7\u3051\u53e3\u304b\u3089\u4f5c\u308b\u3051\u3069\u3001Function App \u306e\u5834\u5408\u306f MVC \u3067\u3044\u3046\u3068\u3053\u308d\u306e Controller \u306e\u30e1\u30bd\u30c3\u30c9\u304c\u76f4\u63a5\u547c\u3073\u51fa\u3055\u308c\u308b\u5f62\u306b\u306a\u3063\u3066\u3044\u308b\u3001\u3068\u601d\u3048\u3070\u3044\u3044\u3002<\/p>\n<p>\u3068\u306a\u308b\u3068\u3001\u3053\u306e\u300cDocker \u30a4\u30e1\u30fc\u30b8\u300d\u3068\u3044\u3046\u3084\u3064\u306f\u3001<\/p>\n<ul>\n<li>\u5185\u90e8\u3067\u3001HTTP \u30b5\u30fc\u30d0\u30fc\u304c\u8d77\u52d5\u3057\u3066\u3044\u308b<\/li>\n<li>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8HTTP \u30ea\u30af\u30a8\u30b9\u30c8\u3092\u3059\u308b\u3068\u3001\u5185\u90e8\u306e MVC \u306e Controller \u3089\u3057\u304d\u3082\u306e\u304c\u8d77\u52d5\u3055\u308c\u308b\u3002<\/li>\n<li>Function App\u306e\u300c\u95a2\u6570\u300d\u3068\u3057\u3066\u3001static \u306a\u30b3\u30fc\u30c9\u304c\u547c\u3073\u51fa\u3055\u308c\u308b\u3002<\/li>\n<\/ul>\n<p>\u3068\u3044\u3046\u30b9\u30bf\u30a4\u30eb\u306b\u306a\u308c\u3070\u3044\u3044\u3002\u5b9f\u306f\u300c\u5185\u90e8\u306e MVC \u306e Controller \u3089\u3057\u304d\u3082\u306e\u300d\u306e\u3088\u3046\u306b\u5206\u96e2\u3055\u308c\u3066\u306a\u304f\u3066\u3082\u3001\u5358\u7d14\u306b HTTP \u30ea\u30af\u30a8\u30b9\u30c8\u3067\u547c\u3073\u51fa\u3055\u308c\u305f\u3068\u304d\u306b\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u3059\u3001\u3068\u3044\u3046\u901a\u5e38\u306e HTTP \u30b5\u30fc\u30d0\u30fc\u304c\u3042\u308c\u3070\u3044\u3044\u306e\u3060\u3002<\/p>\n<h2>Ubuntu \u3067 func init \u3057\u3066\u307f\u308b<\/h2>\n<p>Ubuntu \u4e0a\u3067\u3001Function App\u3092\u4f5c\u308b\u305f\u3081\u306b\u300cfunc init\u300d\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002\u3053\u306e\u3068\u304d\u306b docker \u30b9\u30a4\u30c3\u30c1\u3092\u4ed8\u3051\u308b\u3068\u3001Dockerfile \u3092\u4f5c\u3063\u3066\u304f\u308c\u308b\u3002<\/p>\n<p>func init \u2013docker<\/p>\n<p>\u4f5c\u6210\u3055\u308c\u305f Dockerfile \u3092\u898b\u3066\u307f\u308b\u3068\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\nFROM microsoft\/dotnet:2.1-sdk AS installer-env\n\nCOPY . \/src\/dotnet-function-app\nRUN cd \/src\/dotnet-function-app &amp;amp;&amp;amp; \\\nmkdir -p \/home\/site\/wwwroot &amp;amp;&amp;amp; \\\ndotnet publish *.csproj --output \/home\/site\/wwwroot\n\nFROM mcr.microsoft.com\/azure-functions\/dotnet:2.0\nENV AzureWebJobsScriptRoot=\/home\/site\/wwwroot\n\nCOPY --from=installer-env &#x5B;&quot;\/home\/site\/wwwroot&quot;, &quot;\/home\/site\/wwwroot&quot;]\n\n<\/pre>\n<p>\u3068\u306a\u3063\u3066\u3044\u308b\u3002\u3053\u308c\u306f .NET \u74b0\u5883(C#)\u306a\u306e\u3060\u304c\u3001\u306a\u308b\u307b\u3069\u3001dotnet \u30b3\u30de\u30f3\u30c9\u3067\u30d3\u30eb\u30c9\u3057\u3066 publish \u3057\u3066\u3044\u308b\u3060\u3051\u3060\u3002*.csproj \u306a\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306f\u6240\u8b02 ASP.NET MVC \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u307f\u305f\u3044\u306a\u3082\u306e\u306a\u306e\u3067\u3001\u3053\u3053\u3067\u9069\u5f53\u306a\u95a2\u6570\u304c\u547c\u3073\u3060\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u306a\u308b\u3002<\/p>\n<h2>\u8a66\u3057\u306b func start host \u3057\u3066\u307f\u308b<\/h2>\n<p>func start host \u3057\u3066\u307f\u3088\u3046\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2019\/02\/image-14.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2019\/02\/image_thumb-14.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"486\" height=\"480\" style=\"margin: 0px; border: 0px currentcolor; display: inline; background-image: none;\"><\/a><\/p>\n<p>\u306e\u3088\u3046\u306b\u3001\u666e\u901a\u306b azure function \u306e\u30a8\u30df\u30e5\u30ec\u30fc\u30bf\u304c\u8d77\u52d5\u3059\u308b\u3002\u3064\u307e\u308a\u3001Docker \u306e\u4e2d\u8eab\u306f azure function \u3068\u540c\u3058\u306a\u308f\u3051\u3060\u3002\u307e\u3042\u3001\u540c\u3058\u3060\u304b\u3089\u3044\u3044\u3093\u3060\u3051\u3069\u3002<\/p>\n<h2>docker build \u3057\u3066 docker run \u3059\u308b<\/h2>\n<p>Dockerfile \u304c\u3042\u308b\u306e\u3060\u304b\u3089\u3001\u30ed\u30fc\u30ab\u30eb\u306a Linux \u74b0\u5883\u3067\u3082\u5b9f\u884c\u304c\u3067\u304d\u308b\u306f\u305a\u3060\u3002Ubuntu \u306b docker \u3092\u5165\u308c\u305f\u72b6\u614b\u3067\u3001<\/p>\n<p>sudo docker build -t moonmile\/azure-docker:ver0.2 .<\/p>\n<p>\u306e\u3088\u3046\u306b\u30d3\u30eb\u30c9\u3092\u3059\u308b\u3068\u3001\u30d3\u30eb\u30c9\u304c\u3067\u304d\u308b\u3002Nuget \u3067\u95a2\u9023\u3059\u308b\u30a2\u30bb\u30f3\u30d6\u30ea\u3082\u6301\u3063\u3066\u304f\u308b\u3002<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2019\/02\/image-15.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2019\/02\/image_thumb-15.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"486\" height=\"480\" style=\"margin: 0px; border: 0px currentcolor; display: inline; background-image: none;\"><\/a><\/p>\n<p>\u6b21\u306e\u3088\u3046\u306b docker \u3067\u5b9f\u884c\u3059\u308b\u3002<\/p>\n<p>sudo docker run -it -p 8000:80&nbsp; moonmile\/azure-docker:ver0.2<\/p>\n<p><a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2019\/02\/image-16.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2019\/02\/image_thumb-16.png\" border=\"0\" alt=\"image\" title=\"image\" width=\"640\" height=\"215\" style=\"margin: 0px; border: 0px currentcolor; display: inline; background-image: none;\"><\/a><\/p>\n<p>\u3059\u308b\u3068\u3001<a title=\"http:\/\/localhost:8000\/api\/HttpTrigger1?name=masuda\" href=\"http:\/\/localhost:8000\/api\/HttpTrigger1?name=masuda\">http:\/\/localhost:8000\/api\/HttpTrigger1?name=masuda<\/a> \u3067\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<p>\u6ce8\u610f\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u306f\u3001\u95a2\u6570\u304c\u547c\u3073\u51fa\u3055\u308c\u308b\u3068\u304d\u306b AuthorizationLevel.Function \u306e\u307e\u307e\u3060\u3068\u3001\u30e6\u30fc\u30b6\u30fc\u540d\/\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8981\u6c42\u3055\u308c\u308b\u306e\u3067\uff08Basic\u8a8d\u8a3c\u306a\u306e\u304b\uff1f\uff09\u3001AuthorizationLevel.Anonymous \u306b\u8a2d\u5b9a\u3057\u3066\u3001\u533f\u540d\u3067\u3082\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n<h2>\u81ea\u524d\u306e Dockerfile \u304c\u4f5c\u308c\u308b\uff1f<\/h2>\n<p>\u305d\u3093\u306a\u8a33\u3067\u3001.NET \u74b0\u5883\u306e\u5834\u5408\u306f\u3001AzureWebJobsScriptRoot=\/home\/site\/wwwroot \u306a\u3068\u3053\u308d\u3067\u30eb\u30fc\u30c8\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u308b\u304b\u3089\u3001\u3053\u306e\u3042\u305f\u308a\u3067\u5916\u5074\u304b\u3089\u6307\u5b9a\u306e\u95a2\u6570\u3092\u547c\u3073\u51fa\u3055\u308c\u3066\u3044\u308b\u3093\u3060\u308d\u3046\u306a\u3042\u3001\u3068\u3044\u3046\u3053\u3068\u304c\u60f3\u50cf\u3067\u304d\u308b\u3002<\/p>\n<p>\u3068\u306a\u308b\u3068\u3001PHP \u3068\u304b\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u8a00\u8a9e\u3067\u69cb\u7bc9\u3059\u308b\u5834\u5408\u3082\u3001HTTP \u30ea\u30af\u30a8\u30b9\u30c8\u53d7\u3051\u4ed8\u3051\u308b\u3088\u3046\u306b Dockerfile \u3092\u4f5c\u3063\u3066\u3084\u308c\u3070\u3001Azure Functions\u306e\u4e2d\u8eab\u3092\u300c\u81ea\u5206\u3067\u4f7f\u3044\u3084\u3059\u3044\u8a00\u8a9e\u300d\u306b\u5207\u308a\u66ff\u3048\u3089\u308c\u308b\u3060\u308d\u3046\u3001\u3063\u3066\u3053\u3068\u304c\u5206\u304b\u308b\u3002Linux \u74b0\u5883\u306b\u9650\u3089\u308c\u308b\u306e\u3060\u304c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Azure Functions \u3067\u300c\u306a\u3067\u3057\u3053\u300d\u304c\u52d5\u304f\u3068\u304b\u300cCOBOL\u300d\u304c\u52d5\u304f\u3068\u304b\u3068\u3044\u3046\u8a18\u4e8b\u304c\u3042\u3063\u305f\u30cf\u30ba\u306a\u306e\u3060\u304c\u3001\u3053\u308c\u96e3\u3057\u3044\u306e\u3067\u306f\uff1f\u3068\u306f\u601d\u3063\u3066\u3044\u305f\u304c\u3001\u5b9f\u306f\u5185\u90e8\u3067 Docker \u304c\u52d5\u3044\u3066\u3044\u308b\u3060\u3051\u3060\u3063\u305f\u3001\u3068\u3044\u3046\u8a71\u3002 Azure &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/9739\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,31],"tags":[],"class_list":["post-9739","post","type-post","status-publish","format-standard","hentry","category-dev","category-azure"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/9739","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=9739"}],"version-history":[{"count":9,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/9739\/revisions"}],"predecessor-version":[{"id":9749,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/9739\/revisions\/9749"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=9739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=9739"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=9739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}