{"id":11568,"date":"2019-05-14T16:29:27","date_gmt":"2019-05-14T16:29:27","guid":{"rendered":"https:\/\/www.itwriting.com\/blog\/?p=11568"},"modified":"2019-05-14T16:29:52","modified_gmt":"2019-05-14T16:29:52","slug":"microsofts-pipelines-for-azure-kubernetes-service","status":"publish","type":"post","link":"https:\/\/www.itwriting.com\/blog\/11568-microsofts-pipelines-for-azure-kubernetes-service.html","title":{"rendered":"Microsoft&rsquo;s Pipelines for Azure Kubernetes Service: fixing COPY failed"},"content":{"rendered":"<p>I like to try new technology when I can so following the Build conference I decided to deploy a Hello World app to Azure Kubernetes Service (AKS). I made a one-node AKS cluster in no time. I built a .NET Core app in Visual Studio deployed to a Linux Docker container, no problem. I pushed the container into ACR (Azure Container Registry) though it turns out I did not really need to do that. The tricky bit is getting the container deployed to the AKS cluster. There is a thing called Dev Spaces but it does not work in UK South:<\/p>\n<p><a href=\"https:\/\/www.itwriting.com\/blog\/wp-content\/uploads\/2019\/05\/image-13.png\"><img loading=\"lazy\" decoding=\"async\" width=\"519\" height=\"266\" title=\"image\" style=\"display: inline; background-image: none;\" alt=\"image\" src=\"https:\/\/www.itwriting.com\/blog\/wp-content\/uploads\/2019\/05\/image_thumb-13.png\" border=\"0\"><\/a><\/p>\n<p>I was contemplating the necessity of building a Helm chart when I tried a thing called Deployment Center (Preview) in the Azure portal.<\/p>\n<p>Click Add Project and it builds a pipeline in Azure DevOps for you.<\/p>\n<p><a href=\"https:\/\/www.itwriting.com\/blog\/wp-content\/uploads\/2019\/05\/image-14.png\"><img loading=\"lazy\" decoding=\"async\" width=\"519\" height=\"328\" title=\"image\" style=\"display: inline; background-image: none;\" alt=\"image\" src=\"https:\/\/www.itwriting.com\/blog\/wp-content\/uploads\/2019\/05\/image_thumb-14.png\" border=\"0\"><\/a><\/p>\n<p>It worked but the pipeline failed when building the container.<\/p>\n<blockquote>\n<p>COPY failed: stat \/var\/lib\/docker\/tmp\/docker-builder088029891\/AKS-Example\/AKS-Example.csproj: no such file or directory<\/p>\n<\/blockquote>\n<p>I spent some time puzzling over this error. You can view the exact logs of the build failure and I worked out that it is executing the Dockerfile steps:<\/p>\n<blockquote>\n<p>COPY [&#8220;AKS-Example\/AKS-Example.csproj&#8221;, &#8220;AKS-Example\/&#8221;]<\/p>\n<p>RUN dotnet restore &#8220;AKS-Example\/AKS-Example.csproj&#8221;<br \/>\nCOPY . .\n<\/p>\n<\/blockquote>\n<p>This is failing because there the code in my repository is not nested like that. I eventually fixed it by amending the lines to:<\/p>\n<blockquote>\n<p>\nCOPY [&#8220;AKS-Example.csproj&#8221;, &#8220;AKS-Example\/&#8221;]<br \/>\nRUN dotnet restore &#8220;AKS-Example\/AKS-Example.csproj&#8221;<\/p>\n<p>COPY . AKS-Example\/<\/p>\n<\/blockquote>\n<p>Now the pipeline completed and the container was deployed. I had to look at the Load Balancer Azure had generated for me to find the public IP number, but it worked.<\/p>\n<p><a href=\"https:\/\/www.itwriting.com\/blog\/wp-content\/uploads\/2019\/05\/image-15.png\"><img loading=\"lazy\" decoding=\"async\" width=\"519\" height=\"463\" title=\"image\" style=\"display: inline; background-image: none;\" alt=\"image\" src=\"https:\/\/www.itwriting.com\/blog\/wp-content\/uploads\/2019\/05\/image_thumb-15.png\" border=\"0\"><\/a><\/p>\n<p>Now the Dockerfile has a different path for local development than when deployed which is annoying. I found I could fix this by changing a step in the Deployment Center wizard:<\/p>\n<p><a href=\"https:\/\/www.itwriting.com\/blog\/wp-content\/uploads\/2019\/05\/image-16.png\"><img loading=\"lazy\" decoding=\"async\" width=\"519\" height=\"574\" title=\"image\" style=\"display: inline; background-image: none;\" alt=\"image\" src=\"https:\/\/www.itwriting.com\/blog\/wp-content\/uploads\/2019\/05\/image_thumb-16.png\" border=\"0\"><\/a><\/p>\n<p>Where it says \/AKS-Example in Docker build context I replaced it with \/. Now the build worked with the original Dockerfile.<\/p>\n<p>I also noticed that the Deployment Center (Preview) used a sample YAML template which is linked directly from GitHub and referred confusingly to deploying sampleapp. It worked but felt a bit of a crude solution.<\/p>\n<p>At this point I realised that I was not really using the latest and greatest, which is the pipeline wizard in Azure Devops. So I deleted everything and tried that.<\/p>\n<p><a href=\"https:\/\/www.itwriting.com\/blog\/wp-content\/uploads\/2019\/05\/image-17.png\"><img loading=\"lazy\" decoding=\"async\" width=\"519\" height=\"287\" title=\"image\" style=\"display: inline; background-image: none;\" alt=\"image\" src=\"https:\/\/www.itwriting.com\/blog\/wp-content\/uploads\/2019\/05\/image_thumb-17.png\" border=\"0\"><\/a><\/p>\n<p>This was great but I could not see an equivalent step to the Docker build context. And indeed, the new build failed with the same COPY failed error I got originally. Luckily I knew the workaround and was up and running in no time.<\/p>\n<p>This different approach also has a slightly different shape than the Deployment Center pipeline, using Environments in Azure DevOps.<\/p>\n<p>Currently therefore I have two questions:<\/p>\n<ul>\n<li>Why does Azure offer both the Deployment Center (Preview) and the multi-stage pipeline which seem to have overlapping functionality?<\/li>\n<li>What is the correct way to modify the generated YAML to fix the path issue?<\/li>\n<\/ul>\n<p>I suppose it would also be good if the path problem were picked up by the wizard in the first place.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I like to try new technology when I can so following the Build conference I decided to deploy a Hello World app to Azure Kubernetes Service (AKS). I made a one-node AKS cluster in no time. I built a .NET Core app in Visual Studio deployed to a Linux Docker container, no problem. I pushed &hellip; <a href=\"https:\/\/www.itwriting.com\/blog\/11568-microsofts-pipelines-for-azure-kubernetes-service.html\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Microsoft&rsquo;s Pipelines for Azure Kubernetes Service: fixing COPY failed<\/span> <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":{"footnotes":""},"categories":[2,1519],"tags":[1573,586],"class_list":["post-11568","post","type-post","status-publish","format-standard","hentry","category-net","category-tech","tag-kubernetes","tag-microsoft"],"_links":{"self":[{"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/posts\/11568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/comments?post=11568"}],"version-history":[{"count":2,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/posts\/11568\/revisions"}],"predecessor-version":[{"id":11570,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/posts\/11568\/revisions\/11570"}],"wp:attachment":[{"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/media?parent=11568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/categories?post=11568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/tags?post=11568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}