<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Web FTW</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/wael-kdouh/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/wael-kdouh/feed.xml</link>
    <description>Web: The Ultimate Cross Platform Universe</description>
    <lastBuildDate>Mon, 28 May 2018 22:22:34 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Integrating Angular Unit Tests With Visual Studio Team Services (VSTS) Using Headless Chrome and Puppeteer</title>
      <link>https://docs.microsoft.com/archive/blogs/wael-kdouh/integrating-angular-unit-tests-with-visual-studio-team-services-vsts-using-headless-chrome-and-puppeteer</link>
      <pubDate>Thu, 03 May 2018 19:25:06 GMT</pubDate>
      <dc:creator><![CDATA[Wael Kdouh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wael-kdouh/?p=865</guid>
      <description><![CDATA[In a previous post I showed you how to Integrate Angular Unit Tests with Visual Studio Team Services...]]></description>
      <content:encoded><![CDATA[In a previous <a href="https://blogs.msdn.microsoft.com/wael-kdouh/2017/06/26/integrating-angular-4-unit-tests-with-visual-studio-team-services-vsts/">post</a> I showed you how to Integrate Angular Unit Tests with Visual Studio Team Services (VSTS). Whereas it worked flawlessly it did have dependency on PhantomJS which is a headless browser. The only issue with PhantomJS is that it tends to have some random issues which makes it challenging to integrate within your CI server. Fortunately, Chrome added support for running in headless mode starting with version 59. Thus, you can use headless Chrome to replace PhantomJS.

Start by modifying the Karma.conf.js file and set the browsers property to ChromeHeadless:
<pre class="brush: plain">browsers: ["ChromeHeadless"]</pre>
Remember to remove the npm packages related to phantomjs from your package.json file as they are not required anymore:
<pre class="brush: plain">"karma-phantomjs-launcher": "1.0.4",
"phantomjs-prebuilt": "^2.1.16",
</pre>
Also remove the karma module from your karma.conf.js file:
<pre class="brush: plain">require("karma-phantomjs-launcher")</pre>
Although we are discussing unit tests in this post I will throw a bonus tip and help you modify the end to end tests to utilize Chrome headless as well. You need to modify the protractor.conf.js file capabilities object to include a chromeOptions property:
<pre class="brush: plain">"capabilities: {
    'browserName': 'chrome',
    chromeOptions: {
      args: [ "--headless", "--disable-gpu", "--window-size=800x600" ]
    }
  },
</pre>
At this point you should be able to successfully run your unit tests (and e2e tests) successfully on your CI server. One challenge that arises from using Chrome though is that it needs to be installed globally which can be a bit tricky when using a CI server. Fortunately, there is a project called Puppeteer which is a node library that provides a high-level API to control headless Chrome over the DevTools Protocol. In addition, Puppeteer has an internal module that downloads and installs Chromium (not Chrome as it requires you to accept a License Agreement during installation which requires administrative privileges which in turn defeats the whole purpose of having a local installation). Install it using the following command:
<pre class="brush: plain">npm install --save-dev puppeteer</pre>
Next you will need to place the following code under your karma.conf.js file:
<pre class="brush: plain">process.env.CHROME_BIN = require('puppeteer').executablePath()</pre>

That's it. You should now be able to run your unit tests using headless Chrome and utilize Puppeteer to install Chrome on your CI server.]]></content:encoded>
    </item>
    <item>
      <title>Deploying Your Dockerized Angular Application To Azure Using VSTS - Part 2</title>
      <link>https://docs.microsoft.com/archive/blogs/wael-kdouh/deploying-your-dockerized-angular-application-to-azure-using-vsts-part-2</link>
      <pubDate>Tue, 17 Apr 2018 14:56:09 GMT</pubDate>
      <dc:creator><![CDATA[Wael Kdouh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wael-kdouh/?p=765</guid>
      <description><![CDATA[In part 1 I demonstrated building a VSTS build pipeline which built an Angular docker image and...]]></description>
      <content:encoded><![CDATA[In <a href="https://blogs.msdn.microsoft.com/wael-kdouh/2018/01/02/deploying-your-dockerized-angular-application-to-azure-using-vsts/">part 1</a> I demonstrated building a VSTS build pipeline which built an Angular docker image and deployed it to an Azure Web App for Containers. Whereas it helped me achieve consistency across development and production environments, it required the build server to have all the necessary tools to build the application (Typescript, npm dependencies, Node.JS, etc.). This can be a daunting task and quite frankly unnecessary. In this post I will demonstrate how to eliminate the requirement to install the Angular build tools on the build server and instead utilize a Docker image which encapsulates all the necessary tools.
<h3><strong>Building the Docker Image</strong></h3>
I won't go into the details of creating a DockerFile as it has been discussed extensively in the community. Instead, I am basing my DockerFile on <a href="https://medium.com/@tiangolo/angular-in-docker-with-nginx-supporting-environments-built-with-multi-stage-docker-builds-bb9f1724e984">this</a> excellent post which goes into the details of explaining each step of the DockerFile shown below. Here I have a multi-staged docker build where I am installing the npm packages and building the Angular application in the first image and then copying the final assets from the first image to the final image produced in the second stage. In addition, I am also including a testing steps within the docker build to ensure that only valid images are deployed to production. I am utilizing puppeteer to install headless chrome inside the container as the angular unit and end to end tests need a browser to be present.
<pre class="brush: plain"># Stage 0, based on Node.js, to build and compile Angular
FROM node:8 as node
# See https://crbug.com/795759
RUN apt-get update &amp;&amp; apt-get install -yq libgconf-2-4

# Install latest chrome dev package and fonts to support major 
# charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version 
# of Chromium that Puppeteer
# installs, work.
RUN apt-get update &amp;&amp; apt-get install -y wget --no-install-recommends \
    &amp;&amp; wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    &amp;&amp; sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" &gt;&gt; /etc/apt/sources.list.d/google.list' \
    &amp;&amp; apt-get update \
    &amp;&amp; apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont \
      --no-install-recommends \
    &amp;&amp; rm -rf /var/lib/apt/lists/* \
    &amp;&amp; apt-get purge --auto-remove -y curl \
    &amp;&amp; rm -rf /src/*.deb

# # It's a good idea to use dumb-init to help prevent zombie chrome processes.
# ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
# RUN chmod +x /usr/local/bin/dumb-init

# Uncomment to skip the chromium download when installing puppeteer. 
# If you do, you'll need to launch puppeteer with:
#     browser.launch({executablePath: 'google-chrome-unstable'})
# ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true

WORKDIR /app
COPY package.json /app/
RUN npm install
COPY ./ /app/
# Run unit tests to ensure that the image being built is valid
RUN npm run test
# Run end to end tests to ensure that the image being built is valid
RUN npm run e2e
# Build the angular application with production configuration by default
ARG conf=production
RUN npm run build -- --configuration $conf

# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
FROM nginx:alpine
COPY --from=node /app/dist/ /usr/share/nginx/html
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf
</pre>
It is important to keep in mind that the order of the different docker instructions shown above matters as it will allow us to utilize the caching feature with docker. We start by copying package.json into the container before the rest of the source code, because we want to install everything the first time, but not every time we change our source code. The next time we change our code, Docker will use the cached layers with everything installed (because the package.json hasn't changed) and will only compile our source code. I am using a private build agent on VSTS to ensure that the cached docker layers are not discarded each time the image is built which would lead to increased build times. The final size of the image will be a fraction of the size of the image that includes all the build artifacts which is why I am using a multi-staged docker build. In addition, I am utilizing another great feature with Docker which fails the image build when an instruction returns a non zero exit code. Basically, when a unit test or end to end test fails so will the build as shown here:

<img src="https://msdnshared.blob.core.windows.net/media/2018/04/newimg.jpg" alt="" width="1008" height="689" class="alignnone wp-image-915" />

&nbsp;
<h3><strong>Building a CI/CD Pipeline on VSTS</strong></h3>
Compared to the CI/CD pipeline that I built in <a href="https://blogs.msdn.microsoft.com/wael-kdouh/2018/01/02/deploying-your-dockerized-angular-application-to-azure-using-vsts/">part 1</a> you will notice that I am not including an npm install and ng build tasks as there are not carried inside the docker image.

<img src="https://msdnshared.blob.core.windows.net/media/2018/04/14.jpg" alt="" width="665" height="422" class="alignnone wp-image-835" />

The rest of the steps pertaining to creating an Azure Container Registry as well as building the release pipeline which will deploy to a Web App for Container services will be exactly the same as demonstrated in <a href="https://blogs.msdn.microsoft.com/wael-kdouh/2018/01/02/deploying-your-dockerized-angular-application-to-azure-using-vsts/">part 1</a>.

There you have it, next time you check in your code into VSTS you won't have to worry about installing and maintaining the different build tools on your VSTS build agent.]]></content:encoded>
    </item>
    <item>
      <title>Role of Web Based Technologies In Maximizing Code Sharing In Your Applications</title>
      <link>https://docs.microsoft.com/archive/blogs/wael-kdouh/role-of-web-based-technologies-in-maximizing-code-sharing-in-your-applications</link>
      <pubDate>Thu, 05 Apr 2018 08:42:42 GMT</pubDate>
      <dc:creator><![CDATA[Wael Kdouh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wael-kdouh/?p=785</guid>
      <description><![CDATA[I was recently approached by a colleague of mine with the following question: "What are the...]]></description>
      <content:encoded><![CDATA[I was recently approached by a colleague of mine with the following question: "What are the available alternatives to reduce the current complexity of developing for multiple channels?". In a nutshell he was looking for ways to maximize the amount of client code shared among iOS, Android and Web channels while still being able to use native mobile features if/when needed. So here is the answer I shared with him which I thought would be beneficial for the wider community (not to mention that we love open sourcing everything here at Microsoft these days including our internal discussion threads).

The first question I typically start with is “What are they trying to build”? For example if they require squeezing out every bit of performance then native will always come on top.

The second question I ask is “What is their developers’ skillset”? Now in this case they are coming from native development so they may be open to either C#/XAML or JavaScript(or TypeScript)/CSS/html.

The fact that he threw in the word web presence mixed with requirement for a consolidated code base makes the web sound like a viable option (we still need to address the two aforementioned questions). There are a lot of options with the web today (this could be a good thing or bad thing depending on how you look at it). So lets discuss some options here:
<h3><strong>Browser/WebView Based Solutions</strong></h3>
SPA based frameworks like Angular 5 (it will probably be Angular 6 by the time you read this post), ReactJS, or even VueJS which seems to be gaining a lot of traction recently are excellent options since the same code base used for the web can be integrated within native platform shells like Cordova and Electron. Cordova includes a plugin system that allows you to tap into native iOS and Android capabilities (along with a mini web server that hosts the files inside the shell) and electron which allows you to tap into native desktop capabilities on Windows/Mac/Linux. The catch here is that you are still using the WebView (fancy word for browser plugin within your native application).

PWA is not a framework but rather an enhancement to the web standards. Think about it as an extension to the HTML5 JavaScript Api. Its basically the addition to web Api called Service Workers which introduces offline support, push notifications, as well as creating a native shell for the web app. Now this is a tricky business today as different browsers are at different stages in their PWA journey. For example PWA under chrome is ready for prime time as shown in my recent blog post <a href="https://blogs.msdn.microsoft.com/wael-kdouh/2018/03/08/hosting-an-angular-progressive-web-application-pwa-with-azure/">here</a>. On the other hand Microsoft edge won’t bring support until Spring Creators Update and Safari is yet to add support and currently its only available under its Safari technical preview for Mac (I believe they recently activated it for their iOS). So millage may vary depending on the platform you are targeting, but support is improving every day so we should expect to have a solid PWA story by the end of the year.

WebAssmebly is again not a framework but rather an enhancement to the web. It will coexist with JavaScript and WILL NOT replace it. The idea here is that the web platform is getting a new low-level binary compilation format (think of it as the equivalent of assembly for the web. Hence the name WebAssembly) that will do a better job at being a compiler target than JavaScript. As an added bonus you get to pick the source language to program with and convert that to the binary format. So think programming in high level languages like C++ or C# which will get converted to WebAssembly which you can load along with your JS code. You can even interface with you JS code and vice versa. Most major browsers support it today.

So in summary this option focuses on selecting a SPA framework while augmenting it with great new capabilities of the web like WebAssembly and PWA with the added bonus of integrating all of it within a native shell like Cordova/Ionic and Electron. The main point to remember here is that these solutions allow you to write once and deploy everywhere (web, mobile, and desktop) but will inherit the inherent limitations of the web and will be limited to running inside a browser.
<h3><strong>Native Web Based Solutions (aka Compiled Applications)</strong></h3>
Compiled Web based applications are applications where the UI and the styling are compiled to native code. You typically don’t use CSS and HTML for the UI but instead a markup language that translates to native device code (to Java and Swift/Objective C). So you will be provided with a suite of components that you can use which will be translated to native UI components. Here you will get access to a limited set of CSS like features to keep the syntax you already know but behind the scenes they provide you with an abstraction since CSS is not being used but is simply being provided to make it easier for a web developer to start building UI components. You also use JavaScript for the business logic which will be run by a separate thread spun up in the compiled application.

The first option is NativeScript which can be described as a runtime for building and running "native" iOS and Android apps from a single JavaScript Codebase (you can use Angular or VueJS). This is not Cordova/Ionic and there is no WebView. We are talking about real native components and not Html/CSS/JS based components. So you will not write code that will manipulate DOM elements but instead you will use XML. This option requires you to learn both XML and JavaScript at the same time which may not be for everbody. It runs natively on the OS so you have access to all the native APIs. You can call anything on the device from JavaScript. You can think about it as NodeJS for mobile. It’s basically a V8 JS engine for Android or WebKit’s JavaScriptCore for iOS that sits on the mobile device and runs there and lets you create native apps. This is not Xamarin which cross compiles. There is no cross compilation in NativeScript. The code you write ends up running on the device and you have 100% direct access to Native APIs. Another advantage of NativeScript is that it can be embedded into any existing iOS or Android app which could be beneficial if you have already invested in existing code that you don’t want to rewrite but instead you would like to start developing new features in NativeScript and gradually migrate.

The second option is React Native which is very similar to NativeScript, but instead of using XML for building UI components you use a format called JSX which is a mix of JavaScript and XML. This is an appealing option for those who already have experience with ReactJS since the components will be the same with one main difference which is the renderer (part responsible for rendering the UI), since again you won’t be working with HTML/CSS. So you won’t be using something like &lt;div&gt; or &lt;p&gt; but instead you would use things like &lt;view&gt; or &lt;text&gt; which are mapped to real components within native development. Another advantage of React Native is that it supports ejecting which generates an Xcode project and an Android Studio project which could be beneficial if you decide that native web based solutions is not for you and would like to switch back to developing natively again. Finally, React Native recently introduced a project called React Native for Web which basically allows you to create a renderer that is platform agnostic and thus allows you to use the same code base to run your application on the web which is a big deal when it comes to writing once deploying everywhere.

So in summary this option focuses on utilizing your web skills to build native applications with special markup languages to work with native UI. The advantage here is you get access to all the native device components which means native performance as well. But it comes at a price since you cannot reuse the same code base to deliver the same application through the browser or desktop. React Native for Web has the promise of allowing you to reuse the same code base to have a web presence as well but its still in early stages at the time of writing this post. At this point you could argue that  native web based solutions are not that different from Xamarin Forms. This is a valid argument especially if you factor in the fact that you are having to learn XML (it’s a different XML than XAML), but the main difference is that you will be using JavaScript instead of C# which means that its more accessible to someone who is more accustomed to using web technologies and you can in theory reuse some of that code to build a web/desktop presence.
<h3><strong>Summary</strong></h3>
At the end of the day there are a lot of options available today. There is no good or bad option in my opinion, but rather a viable or non-viable option given the team’s requirements and skillsets. I included a table blow that measures the three different solutions discussed in this post that create a native shell to make it easier for you to decide on the best option for your team.

<img src="https://msdnshared.blob.core.windows.net/media/2018/04/matrix.jpg" alt="" width="754" height="839" class="alignnone wp-image-805" />

* Depending on the nature of the application you are building it might not matter to you. But you may feel the sluggishness in some apps]]></content:encoded>
    </item>
    <item>
      <title>Hosting an Angular Progressive Web Application (PWA) With Azure</title>
      <link>https://docs.microsoft.com/archive/blogs/wael-kdouh/hosting-an-angular-progressive-web-application-pwa-with-azure</link>
      <pubDate>Thu, 08 Mar 2018 17:29:34 GMT</pubDate>
      <dc:creator><![CDATA[Wael Kdouh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wael-kdouh/?p=585</guid>
      <description><![CDATA[Its no secret by now that Progressive Web Applications (PWA) are the future of web development. I...]]></description>
      <content:encoded><![CDATA[Its no secret by now that Progressive Web Applications (PWA) are the future of web development. I won't cover what PWA is in details as it has been discussed extensively in a lot of blog posts including the one I posted a while back which can be found <a href="https://blogs.msdn.microsoft.com/wael-kdouh/2017/06/27/introduction-to-progressive-web-applications-pwa/">here</a>. Please note that both Microsoft as well as Apple have added improved PWA support to Edge and Safari, respectively, since I first published my post about PWA. At the time of publishing this blog post Microsoft Edge has added PWA support under Edge which is included in the latest Windows 10 insider build while Apple has started adding support under the latest Safari Technical Preview. So things will only get better from here for both browsers.

In this post I will show you how you can deploy a Angular PWA application to Azure. I won't show you the detailed steps to build the CI/CD pipeline on VSTS which in turn deploys to Azure as I have already discussed it in a previous post which can be found <a href="https://blogs.msdn.microsoft.com/wael-kdouh/2017/09/11/deploying-your-angular-application-to-azure-using-visual-studio-team-services-vsts/">here</a>. Instead I will focus on some of the pitfalls that you may face while attempting to deploy a Angular PWA application to Azure as it may be tricky to new comers to PWA and mobile development in general. Finally, I will test the application on an Android device running Oreo with the latest version of Chrome. I did not test it on IOS since I did not have access to the latest technical preview of Safari which introduced support for PWA but I will address it in future posts.

I based my application on the PWCAT application which can be found <a href="https://medium.com/@nsmirnova/creating-pwa-with-angular-5-part-2-progressifying-the-application-449e3a706129">here</a>. As mentioned above I setup a VSTS pipeline which deploys my Angular application to an Azure App Service. The image below shows the Angular application artifacts that got deployed to my Azure App Service. Here I am using a very useful feature under Azure App Services called App Service Editor which allows you to browse that artifacts that got deployed to the service. As you can see below its basically the content of the dist folder that gets generated by the Angular Cli build process.

<a href="https://medium.com/@nsmirnova/creating-pwa-with-angular-5-part-2-progressifying-the-application-449e3a706129"><img src="https://msdnshared.blob.core.windows.net/media/2018/03/App-Service-Editor.jpg" alt="" width="421" height="664" class="wp-image-595 alignnone" /></a>

Now I am ready to start running my application on my Android device. If you are lazy like me you probably don't want to type a url into the browser but instead you can use the <a href="https://play.google.com/store/apps/details?id=com.microsoft.azure&amp;hl=en">Android</a>/<a href="https://itunes.apple.com/us/app/microsoft-azure/id1219013620?mt=8">IOS </a>Azure apps which will provide you with access to your Azure portal on the go.

<img src="https://msdnshared.blob.core.windows.net/media/2018/03/14.png" alt="" width="414" height="737" class="alignnone wp-image-605" />

<strong>Tip</strong>: When you browse the application from the Azure Mobile application it loads the http version of the site which breaks the application as Service Workers require https.

The first thing that I noticed when I tried to run the Application on my phone was that the icons I included in the manifest.json file where not being utilized when I tried to add a shortcut to my app on the home page as shown below.

<img src="https://msdnshared.blob.core.windows.net/media/2018/03/23.jpg" alt="" width="375" height="670" class="alignnone wp-image-615" />  <img src="https://msdnshared.blob.core.windows.net/media/2018/03/33.png" alt="" width="376" height="669" class="alignnone wp-image-625" />

<img src="https://msdnshared.blob.core.windows.net/media/2018/03/53.png" alt="" width="377" height="670" class="alignnone wp-image-645" />

Upon further investigation it turns out that the Azure App Service was not serving the manifest.json file. To enable serving json files I went ahead and included the following web.config to the project which enables serving .json files:

&lt;?xml version="1.0"?&gt;

&lt;configuration&gt;
&lt;system.webServer&gt;
&lt;staticContent&gt;
&lt;mimeMap fileExtension=".json" mimeType="application/json" /&gt;
&lt;/staticContent&gt;
&lt;/system.webServer&gt;
&lt;/configuration&gt;

<strong>Tip:</strong> Highly recommend that you utilize the chrome://inspect feature which allows you to debug your mobile browser session from your PC as shown here which helped me uncover the issue:

<img src="https://msdnshared.blob.core.windows.net/media/2018/03/53.jpg" alt="" width="550" height="414" class="alignnone wp-image-655" /> <img src="https://msdnshared.blob.core.windows.net/media/2018/03/7.jpg" alt="" width="2995" height="1919" class="alignnone size-full wp-image-665" />

Refresh your browser and Voila we are back in business. As you can see below I am now able to add a shortcut with the icon specified in the manifest. It even got installed as an application as you can clearly see the icon in the application drawer next to other applications and you can even uninstall it just like any other application.

<img src="https://msdnshared.blob.core.windows.net/media/2018/03/15.png" alt="" width="301" height="535" class="alignnone wp-image-675" /> <img src="https://msdnshared.blob.core.windows.net/media/2018/03/23.png" alt="" width="301" height="535" class="alignnone wp-image-685" />

<img src="https://msdnshared.blob.core.windows.net/media/2018/03/33.jpg" alt="" width="302" height="132" class="alignnone wp-image-695" /><img src="https://msdnshared.blob.core.windows.net/media/2018/03/16.png" alt="" width="300" height="534" class="alignnone wp-image-725" />

A side by side comparison between the version opened under the browser and the version loaded via the app shortcut shows how the chrome is removed to make it feel like a native app.

<img src="https://msdnshared.blob.core.windows.net/media/2018/03/42.png" alt="" width="454" height="807" class="alignnone wp-image-705" />

Finally, the last benefit of PWA demonstrated here is offline support. As you can see below I am able to run the application while in airplane mode instead of being presented with the notorious "your are offline" message.

<img src="https://msdnshared.blob.core.windows.net/media/2018/03/54.png" alt="" width="452" height="803" class="alignnone wp-image-715" />

In future posts I will be sharing my experience running the same application on IOS devices as well as Windows 10 devices which are adding great integration for PWA applications with the Windows store.]]></content:encoded>
    </item>
    <item>
      <title>Deploying Your Dockerized Angular Application To Azure Using VSTS - Part 1</title>
      <link>https://docs.microsoft.com/archive/blogs/wael-kdouh/deploying-your-dockerized-angular-application-to-azure-using-vsts</link>
      <pubDate>Tue, 02 Jan 2018 16:53:17 GMT</pubDate>
      <dc:creator><![CDATA[Wael Kdouh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wael-kdouh/?p=406</guid>
      <description><![CDATA[Introduction

In my previous post I showed you how to deploy your Angular application to Azure...]]></description>
      <content:encoded><![CDATA[<strong>Introduction</strong>

In my previous <a href="https://blogs.msdn.microsoft.com/wael-kdouh/2017/09/11/deploying-your-angular-application-to-azure-using-visual-studio-team-services-vsts/">post</a> I showed you how to deploy your Angular application to Azure using Visual Studio Team Services (VSTS). Whereas VSTS made it extremely easy to build a CI/CD pipeline, there was one challenging aspect which always proves to be challenging and that is the consistency across the development environment and the production environment. For example, when you develop your Angular application locally the application is served by the webpack server wheras when you hosted on Azure its served using IIS. In this post I will show you how you can use Docker containers to use the same environment under both the development and production machines while automating the whole process using VSTS.

I am going to assume that you are developing on a Windows 10 machine. Thus, you will need to install <a href="https://store.docker.com/editions/community/docker-ce-desktop-windows">docker for windows</a> to be able to run docker containers locally. At the time of writing this blog post the latest version of the Angular-Cli was 1.6.2 and the latest version of Angular was 5.1.2. Also I will assume that you have already created an Angular application using the Angular-Cli.

<strong>Building the Docker Image</strong>

We will start by tying docker into the development environment. If you are using VS Code (its no secret by now that its my favorite code editor) I highly recommend installing an extension called Docker that is maintained by Microsoft. It adds the necessary commands to VS Code to add a DockerFile to your existing angular project as follows:

<img src="https://msdnshared.blob.core.windows.net/media/2017/12/Capture.png" alt="" width="685" height="418" class="alignnone wp-image-415" />

Once the DockerFile is added to your Angular application its time to add the necessary commands to assemble a docker image which will be used to create docker containers that will run on both the development machine as well as on the production server. We will assume that nginx will be used as the web server. Here is the DockerFile that builds an image based on the nginx image and copies the dist folder that is generated by the angular build process into the specified directory inside the image.

<img src="https://msdnshared.blob.core.windows.net/media/2018/01/Capture.png" alt="" width="388" height="84" class="alignnone wp-image-425" />

The beauty of the docker image here is that we don’t have to burden ourselves with setting up an nginx server on either the development or production machines. It just works!!! Finally, we are going to expose the web server at port 80 (this is internal to the image and not accessible to the outside world, but more on this later).

If you want to test the above setup locally on your dev machine before you integrate it into your CI/CD pipeline you can build the angular application using the following command:

<strong>ng build –prod</strong>

and then build the docker image using the following command:

<strong>docker build -t my-angular-app</strong>

which would result in the my-angular-app image being created. Notice how the nginx image was automatically downloaded since it was utilized as the base image for the my-angular-app image that we created.

<img src="https://msdnshared.blob.core.windows.net/media/2018/01/Capture2.png" alt="" width="809" height="409" class="alignnone wp-image-435" />

Once the image is created you can run instances of the image (aka containers) from the newly built image using the following command:

<strong>docker run -p 3000:80 -it my-angular-app</strong>

Notice that we had to specify an external port number that would map to the internal port number ( 80 in this case) in order to give access to the outside world as port 80 is only accessible inside the container. You can navigate to <a href="http://localhost:3000">http://localhost:3000</a> which should serve the angular application from within the docker container.

<strong>Building a CI/CD Pipeline on VSTS</strong>

At this point we are ready to automate this process as part of our CI/CD pipeline. Our CI/CD pipeline will include four different tasks as shown in the figure below. Notice that we are using a Hosted Linux agent (still in preview at the time of writing this post) which will have native support for docker.

<img src="https://msdnshared.blob.core.windows.net/media/2018/01/Capture3.png" alt="" width="733" height="495" class="alignnone wp-image-445" />

The first task will install the required npm packages.

<img src="https://msdnshared.blob.core.windows.net/media/2018/01/Capture4.png" alt="" width="648" height="425" class="alignnone wp-image-446" />

The second task will build the application using the Angular-CLI which will place the bundled code under a folder called dist. Here the assumption is that you have modified your package.json scripts section to include a build-prod script.

<img src="https://msdnshared.blob.core.windows.net/media/2018/01/Capture6.png" alt="" width="421" height="267" class="alignnone wp-image-465" />

&nbsp;

<img src="https://msdnshared.blob.core.windows.net/media/2018/01/Capture5.png" alt="" width="652" height="458" class="alignnone wp-image-455" />

The third and fourth tasks will build the docker image and push it to Azure Container Registry (ACR) respectively. Note that I could have used docker hub to store the docker image but I opted to use ACR as I love the idea of reducing network latency and eliminating ingress/egress charges by keeping my Docker registry in the same data center as my deployments. In addition, I wanted to store my image inside a private repository which ACR allows me to do as well.

To create an ACR you can follow the steps below.
<ol>
 	<li>Sign into your Azure Account at <a href="https://portal.azure.com">https://portal.azure.com</a>.</li>
 	<li>In the Azure Portal, choose <strong>New</strong>, <strong>Containers</strong>, then choose <strong>Azure Container Registry</strong>.</li>
 	<li>Enter a <strong>Registry name</strong>, <strong>Resource Group</strong>, and select a <strong>Location</strong>.</li>
 	<li>For <strong>Admin user</strong>, choose <strong>Enable</strong> and then choose <strong>Create</strong>.</li>
 	<li>Wait for the Azure Container Registry deployment to finish.</li>
</ol>
<img src="https://msdnshared.blob.core.windows.net/media/2018/01/Capture8.png" alt="" width="511" height="718" class="alignnone wp-image-485" />

Task 3 and 4 below are utilizing an ACR that I created called waelscontainerregistry.

<img src="https://msdnshared.blob.core.windows.net/media/2018/01/capture.png" alt="" width="1161" height="575" class="alignnone wp-image-495" />

<img src="https://msdnshared.blob.core.windows.net/media/2018/01/capture1.png" alt="" width="1160" height="574" class="alignnone wp-image-505" />

At this point the CI/CD pipeline will create a new docker image every time the code is checked in. Notice that I am using the build number as part of the image name to differentiate the different images that are resulting from different builds. The image below shows the ACR repository.

<img src="https://msdnshared.blob.core.windows.net/media/2018/01/capture3.png" alt="" width="1010" height="740" class="alignnone wp-image-515" />

<span>Now that the image is stored inside ACR we will need to set up continuous deployment of our Docker-enabled app to an Azure web app. Start by creating a Azure web app to host a container. This can be achieved in Azure by creating a "Web App for Containers" as shown below. Notice that I am pointing my web app to the ACR repository that I created in the previous step. At this point you may be thinking that I am hard coding my app to utilize an image with a specific tag number. Don't worry about it as I will override that later on when I push the docker container from within VSTS.</span>

<img src="https://msdnshared.blob.core.windows.net/media/2018/01/capture4.png" alt="" width="1024" height="826" class="alignnone wp-image-516" />

The final step involves creating a release definition on VSTS that will deploy to the Azure App Service we created above. Follow these steps to create a release definition:
<ol>
 	<li style="list-style-type: none">
<ol>
 	<li><span>In the </span><strong>Build &amp; Release</strong><span> hub, open the build summary for your build.</span><img src="https://msdnshared.blob.core.windows.net/media/2018/01/capture6.png" alt="" width="972" height="481" class="alignnone wp-image-535" /></li>
 	<li><span>In the build summary page, choose the </span><strong>Release</strong><span> icon to start a new release definition.</span><img src="https://msdnshared.blob.core.windows.net/media/2018/01/capture5.png" alt="" width="970" height="580" class="alignnone wp-image-525" /></li>
 	<li><span>Select the </span><strong class="x-hidden-focus">Azure App Service Deployment</strong><span> task and choose </span><strong class="x-hidden-focus">Apply</strong><span>.<img src="https://msdnshared.blob.core.windows.net/media/2018/01/capture7.png" alt="" width="1104" height="547" class="alignnone wp-image-545" /></span></li>
 	<li><span>Configure the properties as follows:<img src="https://msdnshared.blob.core.windows.net/media/2018/01/capture8.png" alt="" width="1107" height="548" class="alignnone wp-image-546" /></span></li>
</ol>
</li>
</ol>
The image below shows your completed release definition.

<img src="https://msdnshared.blob.core.windows.net/media/2018/01/capture9.png" alt="" width="1056" height="523" class="alignnone wp-image-555" />

Checking in your code should now trigger your build pipeline which generates a docker container that gets stored inside your ACR. The release management pipeline will pick up the docker image and publish it to your Azure App Service. Both your development as well as your production environment are running the same docker container which is utilizing nginx web server to serve your Angular application. This is a huge benefit as you don't have to deal with unexpected behaviors due to discrepancies in the hosting environments.

In a future post I will show you how to utilize the newly created docker container to start building your application using Micro-Services architecture. Stay tuned...]]></content:encoded>
    </item>
    <item>
      <title>Deploying Your Angular Application To Azure Using Visual Studio Team Services (VSTS)</title>
      <link>https://docs.microsoft.com/archive/blogs/wael-kdouh/deploying-your-angular-application-to-azure-using-visual-studio-team-services-vsts</link>
      <pubDate>Mon, 11 Sep 2017 23:29:23 GMT</pubDate>
      <dc:creator><![CDATA[Wael Kdouh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wael-kdouh/?p=236</guid>
      <description><![CDATA[Introduction
It is no secret by now that the Angular CLI is the preferred method to develop an...]]></description>
      <content:encoded><![CDATA[<h3>Introduction</h3>
It is no secret by now that the <a href="https://cli.angular.io/">Angular CLI</a> is the preferred method to develop an Angular application due to its simplicity and power at the same time. One of the main advantages of using Angular CLI is that it hides a lot of the ceremony involved in creating an Angular application (deciding on a style guide, setting up the package.json file, setting up the client side build system, setting up unit testing, preparing your code for production, etc.).

This is all great, but one sticky point with developers who are accustomed to working Azure has always been the fact that the Angular CLI doesn't provide much information regarding publishing to Azure. This is by design as the Angular CLI is trying not to be opinionated in terms of how you will host your application. In this post I will show you how to build a CI/CD pipeline with Visual Studio Team Services (VSTS) which will deploy your Angular application to an Azure Web App. I will assume that you have already setup the Angular CLI on your machine and that you have already created the Angular application. I will also assume that you have already carried the proper steps to push your code into VSTS.
<h3>Building The Application</h3>
As mentioned above I won't go into the details of creating a new Angular application using the Angular CLI, but I would like to point out that we will need to add a web.config file to <span>instruct our underlying web server on Azure to rewrite all incoming request to serve our </span><em class="markup--em markup--p-em">index.html<span> </span></em><span>file:</span>

<img src="https://msdnshared.blob.core.windows.net/media/2017/09/24.png" alt="" width="771" height="264" class="alignnone wp-image-275" />

We will also need to instruct the Angular CLI to include the web.config file as part of the <span>assets </span>to be included <span>when building our application. We can achive that by adding it the the assets </span>array <span>in </span>.angular-cli.json:

<img src="https://msdnshared.blob.core.windows.net/media/2017/09/25.png" alt="" width="759" height="280" class="alignnone wp-image-285" />
<h3 id="1f75" class="graf graf--h3 graf-after--p">Creating the Azure Web App</h3>
The next step is to create an Azure Web App which will host our Angular application. You can <a href="https://azure.microsoft.com/en-us/free/">sign up</a><span> for a free or paid account and log in the </span><a target="_blank" href="http://portal.azure.com/" rel="noopener noreferrer" class="markup--anchor markup--p-anchor">Azure portal</a><span>.</span>
<ol class="postList">
 	<li id="7227" class="graf graf--li graf-after--p"><em class="markup--em markup--li-em">New -&gt; Web and Mobile -&gt; Web App</em><img src="https://msdnshared.blob.core.windows.net/media/2017/09/125.png" alt="" width="841" height="387" class="alignnone wp-image-255" /></li>
 	<li class="graf graf--li graf-after--p">Fill out the required fields: <img src="https://msdnshared.blob.core.windows.net/media/2017/09/127.png" alt="" width="760" height="1180" class="alignnone wp-image-266" /></li>
 	<li class="graf graf--li graf-after--p">After pressing "Create" you should now have an Azure Web App created.</li>
</ol>
<h3 id="4cbf" class="graf graf--h3 graf-after--figure">Setting Up CI Pipeline With VSTS</h3>
In the next steps we will set up our VSTS CI/CD pipeline to push the Angular application to the newly created Azure Web App. Start by creating a new build definition under VSTS:
<ol>
 	<li><i><i>Build and Release -&gt; Builds -&gt; New</i></i></li>
 	<li>Add an npm task to install the npm packages required by the Angular application<img src="https://msdnshared.blob.core.windows.net/media/2017/09/132.png" alt="" width="750" height="333" class="alignnone wp-image-325" /></li>
 	<li>Add another npm task to build the application and create the dist folder:<img src="https://msdnshared.blob.core.windows.net/media/2017/09/133.png" alt="" width="1847" height="1154" class="alignnone size-full wp-image-326" /></li>
 	<li><span>Add a publish artifact task that generates the dist artifact which will be provided later on as an input to our release definition:</span><span><img src="https://msdnshared.blob.core.windows.net/media/2017/09/134.png" alt="" width="797" height="551" class="alignnone wp-image-336" /></span><span></span><span></span></li>
</ol>
<h3><span>Setting Up CD Pipeline With VSTS</span></h3>
The last step is to add a CD pipeline which will deploy the artifacts created by the build to the Azure Web App. In this demo I am keeping the release pipeline simple by deploying the artifacts directly to production. In a real life application you will probably create multiple environments before releasing to production (Development, QA, Staging, etc.):

<img src="https://msdnshared.blob.core.windows.net/media/2017/09/135.png" alt="" width="687" height="407" class="alignnone wp-image-346" />

The production environment includes a single task that deploys the Angular application to an Azure Web App:

<img src="https://msdnshared.blob.core.windows.net/media/2017/09/136.png" alt="" width="806" height="441" class="alignnone wp-image-356" />

That's it! You now have a fully functional CI/CD pipeline that will deploy your Angular application to an Azure Web App the next time you check in your code.

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>TFVC Source Code Control in Visual Studio Code</title>
      <link>https://docs.microsoft.com/archive/blogs/wael-kdouh/tfvc-support-with-visual-studio-code</link>
      <pubDate>Wed, 06 Sep 2017 19:44:01 GMT</pubDate>
      <dc:creator><![CDATA[Wael Kdouh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wael-kdouh/?p=155</guid>
      <description><![CDATA[In this post I will be walking you through the Team Foundation Version Control (TFVC) support within...]]></description>
      <content:encoded><![CDATA[In this post I will be w<span>alking you through the Team Foundation Version Control (TFVC) support within Visual Studio Code. I will assume that you are running on a windows machine and thus I will be using the TF executable that comes with Visual Studio 2017 (there is also a free, standalone "Visual Studio Team Explorer 2017" version that contains TF.exe). If you are running on a Mac OS or Linux  you can use the </span>Team Explorer Everywhere Command Line Client (TECLC). Regardless of which OS you are running on you should expect the same experience.

First, ensure that you have the Visual Studio Team Services (VSTS) extension installed:

<img src="https://msdnshared.blob.core.windows.net/media/2017/09/113.png" alt="" width="932" height="117" class="alignnone wp-image-165" />

In order to setup TFVC support we need to add one setting in the VS Code settings called "tfvc.location" and set it to the full path of the tf executable which is installed in Visual Studio. Here is the path setup on my machine:
<div>
<div><span>"tfvc.location"</span><span>: </span><span>"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\TF.exe"</span></div>
</div>
<div></div>
<div>With TFVC, the extension uses information about the current workspace to determine how to connect to Team Services. Workspaces can be created using the Visual Studio IDE, Eclipse or with the JetBrains IDEs. <strong>Note:</strong> At the time of writing this post, you will need to have a <strong><em>local</em></strong> TFVC workspace already available on your local machine. Support for Server Workspaces will be added in future updates. More information about the difference between the two types of workspaces can be found <a href="https://github.com/Microsoft/vsts-vscode/blob/master/TFVC_README.md#what-is-the-difference-between-a-local-and-server-workspace-how-can-i-tell-which-one-im-working-with">here</a>.</div>
<div></div>
<div>

I will start by creating an Angular application hosted within an Asp.Net Core 2 application using the newly introduced Angular template with Asp.Net Core 2 SDK under VS 2017.

<img src="https://msdnshared.blob.core.windows.net/media/2017/09/114.png" alt="" width="527" height="391" class="alignnone size-full wp-image-166" />

Now that the application is created and checked into your VSTS/TFS using VS 2017 we are ready to start working with the application from VS Code. The first time you load the project with VS Code you will prompted to run the signin command as you are not connected to Team Services yet:<img src="https://msdnshared.blob.core.windows.net/media/2017/09/115.png" alt="" width="1111" height="31" class="alignnone wp-image-175" />

</div>
You can run the signin command by either pressing F1 and typing in the signin command or clicking on the Team button on the lower left hand side as shown below:

<img src="https://msdnshared.blob.core.windows.net/media/2017/09/117.png" alt="" width="579" height="685" class="alignnone size-full wp-image-195" />

Here you will be prompted with two options to sign in. I highly recommend using the new authentication experience which will automatically generate an access token on your behalf under your account which covers all scopes and is valid for one year. More information about the new authentication mechanism can be found <a href="https://www.youtube.com/watch?v=HnDNdm1WCIo&amp;feature=youtu.be">here</a>.

<img src="https://msdnshared.blob.core.windows.net/media/2017/09/118.png" alt="" width="410" height="91" class="alignnone size-full wp-image-196" />

If you are signed in successfully, VS Code should display the following icons in the lower left corner:

<img src="https://msdnshared.blob.core.windows.net/media/2017/09/119.png" alt="" width="324" height="77" class="alignnone size-full wp-image-205" />

Now if you select the source control tab under VS Code you will notice that the source code control system is TFVC and the included/excluded changes are shown as well. At this point you are ready to check in your changes into your TFVC repository.

<img src="https://msdnshared.blob.core.windows.net/media/2017/09/120.png" alt="" width="734" height="189" class="alignnone size-full wp-image-215" />

Congratulations as you have now setup VS Code to check in your code into a TFVC source code control system. If you are interested in some of the other features that are supported by the extension you can follow this <a href="https://www.youtube.com/watch?v=6IzJ2UPGmoQ&amp;t=83s">link</a>.

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Should I Use Visual Studio 2017 or VS Code For My Next Angular Application?</title>
      <link>https://docs.microsoft.com/archive/blogs/wael-kdouh/should-i-use-visual-studio-2017-or-vs-code-for-my-next-angular-application</link>
      <pubDate>Tue, 05 Sep 2017 18:37:48 GMT</pubDate>
      <dc:creator><![CDATA[Wael Kdouh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wael-kdouh/?p=127</guid>
      <description><![CDATA[I engage with a lot of our customers that work on Angular applications and I frequently get asked...]]></description>
      <content:encoded><![CDATA[I engage with a lot of our customers that work on Angular applications and I frequently get asked the following question: Should we use Visual Studio 2017 or VS Code for our next application? The short answer is doesn't matter because both provide similar capabilities for the most part. In this blog post I will show you how to setup both environments to allow you to be productive when building your next Angular application.

Before I start let me debunk couple myths:
<ul>
 	<li><strong>Myth 1</strong>: Visual Studio 2017 doesn't support folder based projects which is essential for Angular applications that are built using the Angular-CLI. Thus, it is easier to work with VS Code when it comes to Angular projects.</li>
 	<li><strong>Reality:</strong> Visual Studio 2017 now supports folder based projects which makes the experience similar to that provided by VS Code.</li>
</ul>
&nbsp;
<ul>
 	<li><strong>Myth 2:</strong> Visual Studio is a better choice for back-end piece whereas VS Code would be a better choice for the front-end piece.</li>
 	<li><strong>Reality:</strong> Both are equipped to handle both scenarios. With the new Asp.Net CLI tools for example you can now easily build Asp.Net WebApi projects with VS Code as the tools are disconnected from the IDE.</li>
</ul>
&nbsp;
<ul>
 	<li><strong>Myth3:</strong> Use VS Code only if you are working against git based repositories as VS Code doesn't support checking into repositories using TFVC as the version control.</li>
 	<li><strong>Reality:</strong> Both support Git and TFVC.</li>
</ul>
&nbsp;

In this post I will focus on debunking the first myth while addressing the other myths in future posts.

In this example I will assume that you have already created an Angular application using the Angular-CLI. As you can see in the following figure, Visual Studio 2017 allows loading folder based projects. As a matter of fact Visual Studio 2017 installation adds a context menu where it allows you to simply right click inside the folder and load it with Visual Studio 2017.

<img src="https://msdnshared.blob.core.windows.net/media/2017/09/19.png" alt="" width="423" height="180" class="alignnone size-full wp-image-135" />

Here is an Angular project loaded and being served from the terminal using the ng serve command. In this example I am using the Whack Whack terminal emulator extension for Visual studio which can be found <a href="https://marketplace.visualstudio.com/items?itemName=DanielGriffen.WhackWhackTerminal">here</a>.

<img src="https://msdnshared.blob.core.windows.net/media/2017/09/111.png" alt="" width="732" height="611" class="alignnone wp-image-145" />

The same code loaded with VS Code provides a similar experience. Just like Visual Studio 2017,  you can add a <span>context menu ( you have to opt in during installation of VS Code) which allows you to right click inside the folder and load it with VS Code. </span>Here is an Angular project being served from the built in terminal using the ng serve command.

<img src="https://msdnshared.blob.core.windows.net/media/2017/09/112.png" alt="" width="755" height="595" class="alignnone wp-image-146" />

As you saw above, VS Code and Visual Studio 2017 are not meant to replace each another, but rather complement each other. Some people like the experience of a full fledged IDE like Visual Studio 2017 while others prefer the experience of a code editor like VS Code. Regardless of which one you pick you will be productive while developing your next Angular application. Note that at the time of writing this post Visual Studio 2017 is only available on Windows and Mac while VS Code is available on Windows/Linux/Mac as its built using an electron shell.

&nbsp;

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>So What Is WebAssembly All About?</title>
      <link>https://docs.microsoft.com/archive/blogs/wael-kdouh/so-what-is-webassembly-all-about</link>
      <pubDate>Sun, 23 Jul 2017 22:16:23 GMT</pubDate>
      <dc:creator><![CDATA[Wael Kdouh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wael-kdouh/?p=97</guid>
      <description><![CDATA[Every now and then people get excited about a new feature that is being developed as a web standard....]]></description>
      <content:encoded><![CDATA[Every now and then people get excited about a new feature that is being <span>developed as a web standard</span><span>. One such technology that has been garnering excitement lately is called <a href="http://webassembly.org/">WebAssembly</a>. I</span>ts a new way of running code on the web. Think about it as a new sort of application runtime that is available in the browser. Its a subset of normal JavaScript that can be optimized to run extremely quickly (<span>smaller download, much faster parsing in browsers)</span>. The browser can also verify that its safe extremely quickly. The new binary format for delivering that kind of code to the browser is called WebAssembly. Its a low level binary code format that is not meant to be read/written by humans. The idea is that you can compile to this format from some other languages.

The best way to understand such a technology is to see it working. For this demo I will be using emcc to compile c code to WebAssembly. In this example I am creating the fibonacci series for a given positive number.
<div><img src="https://msdnshared.blob.core.windows.net/media/2017/07/code2.png" alt="" width="659" height="706" class="alignnone size-full wp-image-107" /></div>
<div></div>
<div>I used Emscripten which is an open source LLVM-based compiler from C and C++ to JavaScript (C =&gt; LLVM =&gt; Emscripten =&gt; JS). The following command produces the .js and .js.map and the .WASM files:<b> </b></div>
<div><strong>emcc fibonacci.c -s WASM=1 -o fibonacci.js</strong></div>
<div></div>
<div>Next, I loaded the js file in the browser which produced the following results:</div>
<div></div>
<div><img src="https://msdnshared.blob.core.windows.net/media/2017/07/code3.png" alt="" width="413" height="779" class="alignnone size-full wp-image-117" /></div>
<div></div>
<div>As you saw in the example above, I was able to write my code in C and compile it to run in the browser. Here is the browser support for WebAssembly as of June 2017:</div>
<div></div>
<div><img src="https://msdnshared.blob.core.windows.net/media/2017/07/browser-support.png" alt="" width="610" height="274" class="alignnone size-full wp-image-125" /></div>
<div></div>
<div>At the time of publishing this post there is work being done on other languages to be compiled to WebAssembly like Rust and Swift. Steve Sanderson also has an experimental project called <a href="https://github.com/stevesanderson/blazor#getting-started">Blazor </a>that shows .Net being compiled to WebAssembly.</div>]]></content:encoded>
    </item>
    <item>
      <title>How to choose the Mobile Strategy that best suits your company</title>
      <link>https://docs.microsoft.com/archive/blogs/wael-kdouh/how-to-choose-the-mobile-strategy-that-best-suits-your-company</link>
      <pubDate>Tue, 27 Jun 2017 12:28:42 GMT</pubDate>
      <dc:creator><![CDATA[Wael Kdouh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/wael-kdouh/?p=96</guid>
      <description><![CDATA[A lot of companies that are trying to adapt to the proliferation of mobile devices targeting...]]></description>
      <content:encoded><![CDATA[A lot of companies that are trying to adapt to the proliferation of mobile devices targeting different platforms have the following question on their mind today: What is the Mobile Strategy that best suits my company?  This post by Premier Developer Consultant <a target="_blank" href="https://www.linkedin.com/in/waelkdouh">Wael Kdouh</a> outlines some of the things to consider when choosing the strategy that is right for your development team.

As you may have probably read somewhere else, today you are faced with three options that vary in terms of capabilities and development investment:
<ol>
 	<li>Create a web application that supports responsive design.</li>
 	<li>Go native and hence target each platform with its own set of SDKS, IDEs, languages, etc.</li>
 	<li>Go with a cross-platform approach and ‘hopefully’ achieve significant cost savings in terms of code sharing, maintenance optimization, and development team optimization.</li>
</ol>
The first option is to build a web application that may be accessed on any device/platform. This is the simplest in terms of development investment but it does come at a cost. Mainly, it has the following shortcomings when transitioned to the mobile world:
<ol>
 	<li>Makes it challenging to access native device capabilities.</li>
 	<li>No app store presence and hence it makes it harder to distribute and monetize.</li>
</ol>
The second option is to go native. The main advantage of going native is that it offers the best performance and access to the latest UI Controls on each platform. The downside is that the upfront investment can be costly. Basically, you have to invest in multiple tools, teams with different skill sets, platforms, etc.

The third option is the cross-platform approach. This option is gaining more momentum each day as it allows companies to focus more on the business instead of technology. It provides the opportunity to:

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/64/90/metablogapi/1401.clip_image002_01E3BE8F.jpg"><img title="clip_image002" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/64/90/metablogapi/7142.clip_image002_thumb_43EA2DD0.jpg" alt="Share code across platforms, Optimize maintenance costs, Optimize dev team size, Focus on business before technology" width="383" height="110" border="0" /></a>

Today there are several options to achieve cross-platform mobile development that fall into two different categories:
<ol>
 	<li>Hybrid approach.</li>
 	<li>Native approach (not to be confused with native approach mentioned above).</li>
</ol>
The Hybrid approach is mainly driven by <a href="http://cordova.apache.org/">Apache Cordova</a> which is a platform for building native mobile applications using HTML, CSS, and JavaScript. It has been adopted by several tools out there like Telerik’s <a href="http://www.telerik.com/appbuilder">AppBuilder</a> (formerly Icenium) and Adobe’s <a href="http://phonegap.com/">PhoneGap</a> just to name a few. Microsoft also now supports the ability to create Apache Cordova apps right within Visual Studio (both VS 2013 and VS 2015) using <a href="https://www.visualstudio.com/en-US/explore/cordova-vs">Visual Studio Tools for Apache Cordova</a> which is a huge plus for people already using VS as their development environment.

The idea of the Hybrid approach is to host the HTML, CSS, and JavaScript code within a native wrapper which allows it to be installed on the different platforms. Apache Cordova would then use a native browser control to render the application content on each platform. In addition, Apache Cordova utilizes the concept of plugins which is a set of JavaScript APIs that expose the different device capabilities (Contacts, Camera, Cortana, Siri, etc.). The main advantage here is that any existing web skills can be utilized as it uses the same set of technologies.

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/64/90/metablogapi/7658.clip_image004_3E9B471F.jpg"><img title="clip_image004" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/64/90/metablogapi/0317.clip_image004_thumb_2128F613.jpg" alt="clip_image004" width="437" height="226" border="0" /></a>

Native approach (or cross-platform native approach so as not to confuse it with the native approach discussed above) on the other hand embraces developing applications with standard, native user interface controls by providing access to the full spectrum of functionality exposed by the underlying platform and device, including platform-specific capabilities like iBeacons and Android Fragments. One popular tool that exists today for supporting cross-platform native approach is <a href="http://xamarin.com/">Xamarin</a>. With a <a href="http://en.wikipedia.org/wiki/C_Sharp_(programming_language)">C#</a> shared codebase, developers can use Xamarin to write native iOS, Android, and Windows apps with native user interfaces and share code across multiple platforms. Thus, it introduces the ability to share code while providing the performance benefits of a native application. Fortunately, as it is the case with Apache Cordova, Xamarin apps can be built inside Visual Studio as demonstrated <a href="https://www.visualstudio.com/en-us/explore/xamarin-vs.aspx">here</a>.

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/64/90/metablogapi/1616.clip_image006_60F2DC98.jpg"><img title="clip_image006" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/64/90/metablogapi/5428.clip_image006_thumb_35AE4591.jpg" alt="clip_image006" width="448" height="153" border="0" /></a>

At this point we are provided with different options, but the main question still persists: What is the Mobile Strategy that best suits my company?

In order to answer this question you need to consider several factors:
<ol>
 	<li>Skillset of the team responsible for building the application. If your team is more comfortable using web technologies then Apache Cordova may be a better option.</li>
 	<li>Time to Market. There is some upfront investment required with Xamarin as some understanding of the different platforms is required.</li>
 	<li>Shared or Platform specific UI. Xamarin provides a rich suite of UI controls that map one to one with the native counterparts. With Apache Cordova you have to take the responsibility of building these controls yourself (it always helps to check if the OS community may have already implemented it).</li>
</ol>
The above list is not comprehensive by any means, but always keep in mind that the right platform of choice for your individual development effort is totally irrelevant without examining your use cases. For example, if you are developing a simple application then the different cross-platform approaches mentioned above may meet your needs. On the other hand, if you are developing a more complex application that may include several screens, requires performance optimization, and targets wearable technology ( e.g. Microsoft Band, Android Wear, IOS Watch, etc.) then all of a sudden the native approach may seem like a more tempting choice regardless of any other factors. What is truly important depends on who you are and your mobile strategy and needs.]]></content:encoded>
    </item>
  </channel>
</rss>