Mobile First Cloud First

A blog by Geert van der Cruijsen on Apps, Cloud & ALM

Author: Geert van der Cruijsen (page 1 of 2)

Created an open source VSTS build & release task for Azure Web App Virtual File System

I’ve created a new VSTS Build & Release task to help you interact with the (VFS) Virtual File System API (Part of KUDU API of your Azure Web App). Currently this task can only be used to delete specific files or directories from the web app during your build or release workflow. It will be updated in the near future to also be able to list files or to upload / download files through the VFS API.

banner

The reason i made this task was that i needed it at my current customer. We’re deploying our custom solution to a Sitecore website running on Azure web apps using MSDeploy. The deployment consists of 2 parts: an install of the out-of-the-box Sitecore installation and the deployment of our customisations. When deploying new versions we want to keep the Sitecore installation and MSDeploy will update most of our customisations. Some customisations however create artifacts that stay on the server and aren’t  in control of the MSDeploy package that can cause errors on our web application. This new VSTS Build / Release task can help you delete these files. In the future this task will be updated with other functionality of the VFS API such as listing, uploading or downloading files.

The task is available in the VSTS Marketplace and is open source on github.

Let’s have a look how to use this task and how it works under the hood.
Continue reading

Building, testing and deploying precompiled Azure Functions

Azure functions are great to build small specialized services really fast. When you create an Azure Functions project by using the built-in template from the SDK in Visual Studio you’ll automatically get a function made in a CSX file. This looks like plain old C# but in fact it is actually  is C# Script. When you’re deploying these files to Azure you don’t have to compile them locally or on a build server but you can just upload them to your Azure Storage directly.

In the last update for Azure Functions the option to build precompiled functions was added. Doing this is actually pretty simple. I’ve created a sample project on Github containing a precompiled Azure function, unit tests for the function and an ARM template to deploy the function. Lets go over the steps to create a precompiled Azure function.

Continue reading

It’s 2017: Test automation is not optional when building mobile apps!

Note: although this post focusses on mobile app development using Xamarin it also applies to other native mobile apps built in Swift, Java or even web apps. it’s 2017! whatever you are building get started with Test Automation!

As a consultant working for Xpirit i get to see a lot of different customers which I help with my expertise in building mobile applications to improve their mobile apps. Something I noticed in the previous year is that continuous delivery is a hot topic and companies and teams focus on deploying apps automatically to their testers through hockeyapp or even to the stores in beta and / or production.

In agile scenario’s (and come on who isn’t doing that currently? Every company or project I visit is saying they are agile or doing Scrum although some only do dailies and call that scrum 😉 ) In the current world it is really important to be able to release often because you want to be able to adapt to customer needs which are almost always changing and evolving.

Implementing a Shift left Quality Model

Test Automation is a process that does not belong to the developers or testers alone. It’s something that has to be in everyone’s mind from Product Owner to Developer and Tester. Automated tests can help you lower regression test effort but investing in Test Automation can really help you make a shift left focussing on quality earlier in your application development process.

Continue reading

Created an open source VSTS build & release task for Sitecore.Ship

At my current customer we’re implementing an Azure environment which also contains a Sitecore application. We’re using VSTS to for all aspects of the application development lifecycle from agile planning to source control and automated builds & releases. In the release pipeline we can use the out of the box Azure web deploy build steps to deploy our code to our web app which is a Sitecore instance. The next step is to be able to also deploy the Sitecore content we created as code using TDS to our Sitecore Site.

Sitecore.Ship is an open source project which makes it easy to deploy Sitecore .Update files to your Sitecore Instance. It is created by Kevin Obee and it can be found here on Github

in our Build we build our TDS projects using MSBuild to generate .Update files which we can then deploy in our release pipeline to Sitecore. There was one problem however which was that there was no build task to do this. Since my role at my current client is supporting all the development teams in improving their continuous delivery process i decided to create a task to make their life easier.

sitecoreship
Continue reading

Fix “App may slow down your iPhone” popup for Xamarin apps

For a while now (september 2015)  Apple requires apps that are submitted to iTunes to be 64 bit. When building your app for the simulator this isn’t required because app doesn’t go through the Apple screening. Since iOS 10.1 update however Apple added a little popup that checks if an app supports X64 and otherwise will show you a popup telling: “[App name] may slow down your iPhone”. It will only show the error message once and is meant for old apps which are added to the store before september 2015 and are still on peoples phones/tablets who need to update to X64.

Popup message: [App name] may slow down your iPhone

Screen Shot 2016-11-08 at 22.09.46

The fix is quite easy. just set the iOS build to support X64 also when building for the simulator.

Xamarin Studio

in Xamarin Studio go to properties of your iOS project. by rightclicking your iOS project. -> iOS Build tab  -> make sure that Supported Architecture for each configuration contains X86_64 or i386 + x86_64

Screen Shot 2016-11-08 at 22.08.58

Visual Studio

in Visual Studio right click your iOS project and select properties. -> go to iOS Build -> Advance tab ->make sure that Supported Architecture for each configuration contains X86_64 or i386 + x86_64

Screen Shot 2016-11-08 at 21.45.38

 

Although this is a small issue i got some questions by new developers what this message meant. so hopefully this blogposts helps those who were questioning why this message is showing up all of a sudden.

Happy coding!

Geert van der Cruijsen

Adding an Azure web app to an Application Service Environment running in another subscription

Web apps and Api apps  in Azure are great, however when using them you have to agree to have them connected to the internet directly without the possibility of adding a WAF or other kind of additional protection (next to the default Azure line of defense). When you want to add something like that you have to add an Internal Application Service Environment to host your apps so you can control the network access to these apps.

App Service

However adding an Application Service Environment is quite costly if you are only running a few apps in them. (Minimum requirements for an Application Service Environment are 2 P2’s and 2 P1’s to run the Application Service Environment (ASE)

In our case adding an ASE was fine except that we have a scenario where we have quite a lot of subscriptions and most of them are quite small running only a couple of apps in them. Adding an ASE for each subscription was going to become a bit to costly so we came up with the idea of creating 1 central subscription called “Shared Services” where we would host things that multiple departments could share such as WAF functionality, the VNet, the Express route and also the ASE.

After creating the design we ran in to some problems actually implementing it because we weren’t able to select an ASE in another subscription which was part of the same enterprise agreement when creating an App Service Plan or Web App in Azure.  After checking it seems that this is a limitation of the Azure Portal and we had to use ARM templates to create our web app. This didn’t matter because we were planning on using ARM templates anyway. so we started to give it a try.

At first we had some trouble adding the ASE as our hosting environment. we tried adding the “HostingEnvironment” to point to the name of the ASE in our other subscription but this did not work and we kept receiving errors like “Cannot find HostingEnvironment with name *HostingEnvironmentName*. (Code: NotFound)”

ASE erorr message

 

After that we tried to remove the “HostingEnvironment” property and only set the “HostingEnvironmentID” to directly link to the full resourceID of our ASE. this did get our hopes up because we were able to deploy the web app, however it was running on the P1’s that were part of the workerpool of our internal ASE but it still had a public dns name and was accessible from the internet. I guess we weren’t supposed to created it this way. so i asked help from the Microsoft product team and they pointed me to the right correction.

It all boils down to using a newer API version of the Web App and App Service Plan ARM template API than that are generated in visual studio when building ARM templates. we had to use apiVersion: 2015-08-01

in here we can set the “hostingEnvironmentProfile” to the full resourceID of our ASE for both the App Service Plan as the Web App. Next to that we also have to set the sku to the correct worker pool within our ASE.

Now when we try to deploy our ARM template it will actually create an App Service Plan and Web App in another subscription than where our ASE is running. Nice!

Hopefully this post will help you when you run in to the same problems i did when trying to deploy web apps in an ASE using ARM templates.

Happy Coding / Deploying

Geert van der Cruijsen

Techdays 2016 slides & Recap

Last week 4 and 5th of October Microsoft organized Techdays in the Netherlands and the full Xpirit team was there as platinum sponsor. We organized lots of cool things such as the Techdays Minihack zone where people could get hands on expierence and compete for cool prizes.  Xpirit was also the supplier of the official Techdays app which we open sourced during Techdays. The source can be found here on github: https://github.com/XpiritBV/app-evolve

 

As Xpirit we delivered 17 sessions and had 7 speakers on the event.  I delivered 2 sessions on Xamarin topics. Here are the slides for the sessions. The Videos are coming later (and will be in Dutch).

Xamarin Test cloud – From zero to hero in automated UI testing

Session abstract:

Looking at the mobile device landscape it became almost impossible to do manual testing on all types of devices that your customers use. Not even thinking about what your app looks like on some very rare Android devices. To ensure great quality of your apps you’ll have to introduce automated UI testing and Xamarin Test cloud can  be the tool for the job. During this session Geert will show how to  start building automated tests for mobile apps to demonstrate the features of Xamarin test cloud and how it could help you in your app development cycle. ‘Geert will give best practices and tips on what to test and what not to test and how to structure your tests. Join this session if you want to ensure your apps look great on all devices.

Slides:

Video: (in Dutch)

 

Techdays 2016 app: Behind the Scenes

Co-presenter: Roy Cornelissen

Session Abstract:

Every conference needs a good mobile app. During this session Roy and Geert will take you through the story of how they’ve built the Techdays 2016 app for iOS, Android and the Windows platform using Xamarin.Forms. They will show you cool stats of the app, it’s architecture, cool features we added and how we added them and lessons learned while building this app.

Slides:

Video: (in Dutch)

 

Next to all the cool sessions and minihacks we’ve delivered at Techdays we also launched a new issue of our magazine “Xpirit Magazine”. this magazine contains a lot of cool technical articles written by my colleagues and me. We handed out the magazine to everyone at Techdays but if you missed it you can still get a free copy (either pdf or FREE hardcopy)  here: xpir.it/magazine-3

XpiritMagazine_cover_large-1 (1)

articles covered:

CONTINUOUS DELIVERY 3.0
■ Continuous Delivery 3.0 – The next ‘next step’
■ Release management, from technical to functional practice
■ Infrastructure as Code
MOBILE
■ Mobile Innovation – Don’t wait for the ‘perfect’ app
■ Exploring the Microsoft Bot Framework
■ Continuous Delivery 3.0 for Mobile apps
ALM
■ Extending your Build and Release pipeline
■ Technical Debt you application Lifecycle
■ Doing testing right
CLOUD
■ Containers on the Microsoft platform: the full picture
■ Conquer the world with Azure Machine Learning
■ How to accelerate your choices using data

 

Hope to see you next year on Techdays. Xpirit will definitely be there!

Geert van der Cruijsen

Upgraded my blog to Project Nami on Azure

My blog has been running on WordPress in combination with Microsoft Azure since the start. I always disliked the fact that i had to get a MySQL database using ClearDB to host it but it seemed the only way. A few days ago i made some mistakes and kinda broke my current blog (i won’t bother you with the details 😉 ) and had to do some reinstalls. Since quite some time passed i thought it might be good to do some research in the current possibilities of using native azure components for my datastorage.

the first thing i found was using MySQL in app with your Azure web app. This removes the dependency of ClearDB but you’ll still have some limitations such as being limited to a single instance and no features for access your database remotely.

Screen Shot 2016-09-01 at 08.28.08

more info on MySQL in App preview:  https://blogs.msdn.microsoft.com/appserviceteam/2016/08/18/announcing-mysql-in-app-preview-for-web-apps/

When i looked a bit further i found another cool project called “Project Nami“. Nami stands for Not Another MySQL Install and is a fork of WordPress that changed the database layer to talk T-SQL so they could add SQL Azure as the database layer.

ProjectNamiLogo

Installing it was pretty easy. you can just get it from the Azure Marketplace when you search for “WordPress” or “project Nami” and after that it was installed in a few minutes.

Screen Shot 2016-09-01 at 08.33.16

I have to say the performance is great! the initial costs seem to be lower than they were before and my blog seems to be a lot more responsive. I really liked the upgrade to Project Nami so thought I share it with you so you might consider making the same switch if you are still running wordpress + mysql on Azure.

One downside of my screwing up my previous blog instance is that all comments are kinda lost. so thats why you might not see any comments on my older posts anymore.

Geert van der Cruijsen

 

Xamarin DevDays Amsterdam Recap

Yesterday  we organised one of the many Xamarin DevDays events in our Xpirit office in Amsterdam. It was great to see many people show up on such a sunny day in the weekend (Some of them coming all the way from London to attend this event here).

The day was split into 4 parts.

 

14051741_1239068676138188_4762360838751043582_n

All slides, samples and labs  can be found on github here: https://github.com/XpiritBV/dev-days-labs

Even if you weren’t at the event  the labs might be to interest of you because they contain some really nice detailed steps on how to create a Xamarin.Forms app including a Azure backend.

 

Xamarin Apps

14095850_1239068642804858_599288069959767511_n

Marcel kicked of the day by explaining how to build true native apps using the traditional Xamarin approach.  How we can share up to 70 to 80% of our code while still having all features we would have when building native apps in Objective-C, Swift or Java. By building apps using Xamarin you have the possibility to use all the native tools to build your UI, you can create storyboards for iOS, define your Android UI in AXML and on Windows you can create your UI in XAML. These native UI’s connect to your business logic which you can write in C# and can be the same for all platforms.

Screen Shot 2016-08-28 at 13.01.45

Marcel also talked about the performance and how Xamarin apps can often even beat Java or Objective-C apps in performance. This is possible because on android the Mono runtime is sometimes just faster as the Java runtime on Android devices.

There are also some differences on how  your code will be compiled and published to the different devices. Android makes use of  Just in Time compilation in combination with IL code while on iOS a ARM-Binary is created using Ahead of Time compilation to build true native apps.

Screen-Shot-2016-08-28-at-13.02.02 (1)

14054243_1239172942794428_4862573752858820030_n

Xamarin.Forms

Then it was my turn to take the stage to do an introduction on Xamarin.Forms. Xamarin forms is library built my Xamarin to increase code sharing even further. you could go up to 99% code sharing with Xamarin while your apps still look and perform natively.

Xamarin forms is a UI framework that creates an abstraction on top of the UIs for Android, iOS and Windows and will let you design and create these UIs in your shared code which will then be turned into real native UI components when you compile for iOS, Android or Windows. if you use things like Tabbed pages the tabs will be placed at the bottom for iOS because that is what iOS users expect, and for Android it will create beautiful material design tabs at the top of your screen.

Screen-Shot-2016-08-28-at-13.02.36 (1)

You can define your Xamarin.Forms UI using XAML or C# and there are over 40+ pages, layouts and controls available.

Screen-Shot-2016-08-28-at-13.02.55 (1) Screen-Shot-2016-08-28-at-13.03.05 (1)

14063932_1239172959461093_6424750382214445463_n

Xamarin + Azure

After lunch Roy told a great story on how azure can help you speed up the development process of building your mobile backend with all the features that come with Azure.  We zoomed in on Azure Mobile apps and al the components that help you create mobile back ends and adding offline data synchronising between your mobile and the mobile backend with just 4 lines of code!

Screen-Shot-2016-08-28-at-13.03.59 (1)

14064284_1239173046127751_4605706219513382693_n

In the afternoon we spend some time with all the people who attended on building the labs or discussing different Xamarin questions. It was great to see all the people who were new to Xamarin being able to pick this up so fast and were able to write a simple app in a couple of hours.

If you missed this Xamarin DevDay in Amsterdam make sure you check the posts by Xamarin where they announce more of then during the coming months. Xlevelupmobile_logorgbpirit is also organising another Mobile development related event on 22nd of September together with AFAS. This FREE event is called LevelUp Mobile and we have great speakers like  Brechtje de Leij (mobile strategist and expert),  Laurent Bugnion, Jorn de Vries of Flitsmeister, Johan Gorter & Rick Hoving from AFAS Software & Roy Cornelissen and me From Xpirit . Sign up here: http://www.levelupmobile.nl

Happy coding! Geert van der Cruijsen  

Xamarin apps: Sqlite vs Realm. What’s the best mobile DB solution?

Last week Realm.io introduced Realm for Xamarin. Realm promises an easy object database with full query options and better performance than existing solutions (so also sqlite which is probably the most used database solution). Time to put both sqlite and Realm to the test. which is better?

SqlitevsRealm (2)

When comparing these solutions i wanted to test out the full relational options of the database because that is what Realm advertises with. if we are looking at just plain key value storing we could use something like akavache (based on sqlite back end) which is probably faster because of lots of optimisations in queries. I do recommend using akavache for caching scenarios or when you are just storing simple types of data that do not require complex querying.

To test sqlite and Realm i’ve created a simple datamodel with orders and order lines. each order has a list of order lines and i would like to be able to query orders and get the underlying orders back immediately. but also the other way around. i would like to query certain orders which have order lines that contain a certain product. those kind of queries happen often when you are working in a real world business app.

So now we have this datamodel + some queries we want to execute. lets define some criteria on how to score both solutions. I came up with the following critters: Ease of use, speed, & maintainability.

let’s talk about these criteria in a bit more depth. I’ve created a sample project on github that has the samples and source code for you to experiment.

You can download the source here: https://github.com/Geertvdc/Xamarin-RealmVsSqliteCompare

Ease of use

Sqlite and Realm are both pretty easy to set up. I’ve used Sqlite in the past before and had never used Realm so i had to do some reading up on Realm. I didn’t have to read that much though because the basic explanation of Xamarin.Realm on the Realm.io site explains the most used features and all the features i need for this first test.

Realm is actually really simple to set up. Where Sqlite does require some plumbing (getting a location for a file to store your DB in and creating a SqlAsyncConnection) this is not needed for Realm. In Realm you can just call the GetInstance(); method and you are ready to go. For both we need to install nuget packages of course which can be though for sqlite as well since there are so many different packages it’s sometimes hard to know which ones to use.

Sqlite needs 3 nuget packages for the basic functionality:  SQLite.Net-PCL, SQLite.Net.Core-PCL and SQLite.Net.Async-PCL. next to that i use 2 extra packages to give me some extra extension methods: SQLiteNetExtensions & SQLiteNetExtensions.Async.

For Realm we just need to add Realm nuget package to all our projects.

After we have an instance of both Sqlite and Realm we can start inserting some data into our database. Below is some sample code to insert 1000 orders which each have 5 order lines. I want to be able to insert all of them and make sure that there is a relation stored between the orders and the order lines so i can retrieve both in 1 query.

Looking at the code Realm just works a bit easier. we don’t have to think about doing sql transactions (if you forget/remove the transaction it is about 3x slower.) We just need to create the objects in a Realm.Write block and Realm will handle all the things for us. I do have to say i’m no fan of having my database objects have to inherit from RealmObject and that the constructor has to be Realm.CreateObject() but more on that in the Maintainability criteria. When looking at ease of use only i have to say Realm is easier because it does all the plumbing and yak shaving for you. Winner: Realm

Speed

Realm promised us a faster database than the competition so this was the reason i started this investigation. Sqlite can be slow some times but most often this is because of bad use. Paul Betts (creator of Akavache) did a great session at Xamarin Evolve this year on why sqlite is often slow and how to use it properly. To test the speed I’ve created a xamarin forms app and ran some tests on both Android and iOS. speeds do change a bit from platform to platform and also there is a some difference in using a device or emulator/simulator. Overall Realm seemed a bit faster in querying complex queries and it seems to use some caching looking at the query that took 0 ms on iOS. A note here is that Sqlite can probably be even a bit faster when you optimize the queries. What i used now for Sqlite is just a generic query to retrieves all objects with it’s children.

Screen Shot 2016-05-17 at 13.52.12 Screenshot_20160517-135540

After looking at the test data there are some differences and sometimes Sqlite is faster then Realm and the other way around. Sqlite can be fast if you know what you are doing and Realm seems to do the job quite well without any special thought on how to do things like transactions. scoring points for ease of use again.

Winner: No clear winner between Sqlite & Realm purely regarding speed

Maintainability

The last criteria on which i wanted to test these 3 solutions is maintainability. Sure the ease of use of Realm seems nice but how would this work in actual apps that need to be maintained and tested for long periods of time.

The first think i noticed when looking at Realm is that all your database object need to inherit from RealmObject. Because of this inheritance Realm knows how to do all it’s magic but i really don’t like this approach. creating objects cannot be done by using a simple constructor you always need to use Realm.CreateObject, creating a tight reference to Realm. Same goes for the lists of objects within a RealmObject which have to be of the type RealmList<T>. I like Sqlites approach much better where you just use simple POCOs (Plain Old CLR Objects) with some attributes attached so Sqlite knows how to store certain things.

In a proper testable software architecture you want to keep the dependency on either Realm or Sqlite to a minimum of places and preferably only in the classes that handle the database communication. for Sqlite this is possible however for Realm this will be quite hard since creating new objects can only be done by Realm.CreatObject. You could do a mapping from Realm to POCOs in your repository but that defeats the purpose of the ease of use of Realm which offers functionality for listeners on object changes to easily update your UI.

another thing that is really missing from Realm is support for Async. In my opinion every mobile library should have async features as default (or as only option). It is on the “missing features” list of Realm so they are aware that this is an important feature. But at it’s current state in the beta it’s not in.

The last thing i noticed was the Fody Weaver that is being used by Realm. At first it’s not that important for you as a developer because it just works. the weaver will do some changes to your IL to add stuff Realm needs. As long as everything works it’s no problem, however when you run into problems you might have issues finding the issue because the code that is being executed is actually a bit different from what you wrote.

Combining these things related to maintainability i think Sqlite is a clear winner here.

Winner: Sqlite

Conclusion

Looking at these 3 criteria i think Sqlite is still the best solution. Sure Realm is pretty fast and needs almost no plumbing i think the maintainability of Sqlite will win it in the end. I do see some use for Realm, especially for POC’s or small projects. (although for POCs i have to much experience of POCs running in production in the end or growing to larger apps, if that is the case i would pick Sqlite).

We have to take into account that Realm is still in beta and Sqlite has been there for ages but the things i don’t like about Realm are basically in it’s base so i don’t see them changing that quite soon. I’ll be watching Realm to see what they are up to in the future but for now i’ll keep using Sqlite.

Let me know your experiences with Realm in the comments below. i’m curious if people have different opinions than me after playing with it for a few days.

Happy Coding

Geert van der Cruijsen

Older posts