Understanding NetStandard

Understanding NetStandard

I was working on DayTickler and authentication when the latest Azure Mobile Client was released. Being fearless, i decided to upgrade.

Turns out the new version of the nuget doesn`t support pcl, but netstandard. No problem, let`s upgrade everything to netstandard, i need it for things like the latest AutoMapper anyways.

NetStandard is the new name for portable libraries. They are not built X time for each platform but offer binary compatibility for each platform. For example, uap10 implements netstandard 1.4, meaning that any UWP project can target libraries of type netstandard 1.4 because it provides and implementation of all the 1.4 level api…

It`s really complicated, but i always go back to this post, mainly for this table :

.NET Standard 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0
.NET Core 1.0 1.0 1.0 1.0 1.0 1.0 1.0 2.0
.NET Framework (with tooling 1.0) 4.5 4.5 4.5.1 4.6 4.6.1 4.6.2
.NET Framework (with tooling 2.0 preview) 4.5 4.5 4.5.1 4.6 4.6.1 4.6.1 4.6.1 4.6.1
Mono 4.6 4.6 4.6 4.6 4.6 4.6 4.6 vNext
Xamarin.iOS 10.0 10.0 10.0 10.0 10.0 10.0 10.0 vNext
Xamarin.Android 7.0 7.0 7.0 7.0 7.0 7.0 7.0 vNext
Universal Windows Platform 10.0 10.0 10.0 10.0 10.0 vNext vNext vNext
Windows 8.0 8.0 8.1
Windows Phone 8.1 8.1 8.1
Windows Phone Silverlight 8.0

 

Also, if, along the way, you wish to include non netstandard libraries in your netstandard library,  you can modify your project.json like this :

“frameworks”: {
“netstandard1.4”: {
“imports”: [ “portable-net45+win8+wpa81” ]
}
}

It helps !


Microsoft Build 2017 WishList

Microsoft Build 2017 is right around the corner, with keynotes streaming live in about 24 hours !

This is my reading of the Windows ecosystem, and what i would like to see announced… My new thinking is that an operating system is just a management thing, the APIs are all similar now… there is no reason i should be choosing my OS based on the apps available but rather how i want to manage it. Oh, and the web with PWA apps is going to kill it all…

The big messages are :

  • Make Windows shine as a managed platform.
  • Every Windows device should be an Android device ++. We need the apps.
  • Every desktop-laptop Windows device should be a Linux device ++, this will bring in the entire academic and scientific public to Windows.
  • Make Windows cloud first, mobile first. Make it sync my life. Make it replace my phone. force a eSIM in every device and provide the service. Help us get ride of our telcos with take our money and offer zero innovation.

Here is the detailed list…

  1. Win32 Apps can now be on the store, and run everywhere windows can (desktop, laptop, tablets with ARM and Intel), you require a traditional Windows license to run Win32 outside of the store.
  2. UWP for redstone3  is the new API to build professional apps. The API surface will be augmented so that it is years ahead of any other API we have to build apps. It is 3d ready, mobile ready, cloud ready, sync ready… Works everywhere like RPI, desktop, laptop, tablets, phones, xbox, smart tvs.
  3. Xamarin is the way to build cross platform stuff using Microsoft technologies. These apps will shine on Windows and Xamarin will provide some sort of universal platform service API to compete against the Google PLAY specific APIs.
  4. Android apps can be downloaded from the Windows Store on any platform and things just work. Developers only need to submit their APK to the Windows Store. If you can’t beat them, join them. Microsoft has to differentiate itself by offering a better management platform and THE API to develop professional apps. An Android page exists in the settings app to manage the interoperability.
  5. A single shell that adapts to every device seamlessly (CSHELL), extend Continuum.
  6. An interface that doesn’t make me jealous of iphones (NEO).
  7. The development pace for EDGE will augment and will now be distributed in the store so that PWA is fully supported by redstone3. Also web sites will be deeply integrated into the OS and will not feel any different than UWP apps.
  8. EDGE will be enhanced to become the premier note taking and research tool. Complete integration with OneNote.
  9. Skype for UWP actually made usable and will integrate functionality for Skype for business.
  10. Skype will offer SkypeIn to everybody on earth so that i can answer the phone from my phone, laptop… With good rates on roaming and data. All Windows tablets should be eSIM compatible.
  11. Office will get it’s act together and put in the store great apps, current mobile office apps will remain as readers and light editors for the road.
  12. LXSS (linux subsystem for windows) will become official (not just a developper feature) in Windows PRO and have a it’s own page in the settings app.
  13. When you launch a feature, launch it globally
  14. Make Cortana able to have conversations, enhance it with bots.
  15. Indirect displays (Display link based USB monitors) will be made super efficient (this is a pet peeve since the new driver architecture)

On the hardware side…

  1. Come out with a small dongle that costs 50$, feels like a Roku with a remote like the Roku, and supports miracast, dlna – upnp, EDGE browsing with the wireless air mouse remote, continuum and UWP apps. Call it the YBOX or something. Make it do everything the XBOX can (minus heavy gaming) for 50$. The YBOX is even integrated in monitors and TVs.
  2. Come out with a surface phone that is the center of my life. It has an accessory called Surface which is basically a tablet (8, 10 or 12 inches) and a pen which is basically a second screen for my phone. Requires a Surface Phone to work otherwise you are limited to browsing the web with EDGE via WIFI. Can display any app that my phone is running (win32, UWP, android, PWA) via some Continuum technology. Can extend to my other Windows devices in seamless way.
    For example I turn on my laptop and see Visual Studio in my task bar (running on my laptop) as well as Facebook (an android app running on my phone but being broadcast to my laptop) as well as Twitter (running on my laptop but state being pushed from phone because the apps are both UWP and can sync state).
  3. Keep the Surface Pro, Surface Laptop and Surface Studio lineup as is…

On the media side…

  1. Support live tv and radio by region for a base streaming fee (5-6$ per month), allow plugins for cable providers (i.e. Videotron, Bell or even Netflix)
  2. Support magasines and newspapers as well as ebooks in the store, have an all you can read package for 10-15$ per month).
  3. Google gobbled up Songza… get your hands on DI.FM, evolve it a bit and offer it everywhere for a base streaming fee (3-4$ per month).

 


SQL and extensibility

Having a schema in SQL defeats extensibility – and there is no way i am having columns named “ExtensibleColumn1, ExtensibleColumn2″…

I have come to embrace storing JSON directly in the database, quite easy actually as JSON is simply text…

The bigger problem though was how to extract specific data from this JSON, or filter on it… and here is the solution: OpenJSON !

 


SQL Magic row to column concatenation

Imagine you have a very simple data model with two tables, Invoice and InvoiceTaxes.

When creating a report, i would like to see all invoices and the taxes applied to each, but not as a 1 to n relationship, but rather as a sting concatenation.

i.e.

Invoice1, “TPS”
Invoice2, “TPS, TVQ”
Invoice3, “TVH”

I went around and found a bunch of different ways on StackOverflow, everyone single one looking super duper complicated…

Then i found something called String_AGG, and it’s available on Azure SQL right now !

select invoiceid,
(select string_agg(taxname, ', ') from invoiceTaxes where invoiceTaxes.invoiceID = invoicesid) as Taxes
from invoices

Voilà !


Windows 10 Creator`s update

I have been using the new Windows 10 Creator`s update on my main laptop now for a few days, and things are pretty smooth. The upgrade process didn`t break anything…

The good :

  • Taking screen shots and putting them to the clipboard is not built in. It is the same combination as OneNote used. windowKey + Shift + s
  • Edge seems fast
  • Paired with the latest DisplayLink drivers (8.2) my system doesn`t get as slugish as before
  • The tv and movie apps has a windows on top mode so i can catchup on movies as i work without taking half the screeen
  • Skype is out of preview and actually kinda works. Paired with my phone i can now answer SMS from the desktop without having to take my phone and unlock it each time

The bad :

  • Someone decided that the new window on top feature in skype should activate as soon as skype loses focus. This is horrible when trying to answer email on a second screen when watching a demo which  is streamed to skype.

This is not meant as an exhaustive list of all of the new features, but mainly what i have used a lot since the I have installed the new version.

 


Application Insight Availability

I just helped put a rather big system in production. There are always a lot of things to do and we lately turned on availability monitoring with Azure Application Insights.

Since we knew we were going to use this feature, we had added a “ping” controller to our API tier. This controller had a single method called “IsAlive”. It returns a 200 if it can access the database and a 400 if not.

5 minutes after we turned on monitoring, we were able to visualise the latency from 5 spots on the internet likely to have clients using the system. If something fails, we get alerts thrown that tell us when the system falls and when it gets back online.

Doing this a few years ago would had required specialised tools and now, it is a few clicks away in all of the major platforms. Use it, it’s five minutes to ensure you are warned if a problem arises.


Azure and Memory Leaks

I know I know, how can i have memory leaks, you’ve got a garbage collector in that fancy .net don’t you ?

So this is the second project i work on where we find memory leaks in production. The first one was a third party library that didn’t release a bitmap when it generated reports using it, the second one wants to hold on to Entity Framework contexts after they’ve been used.

Not much i can do about the first case cause i don’t have access to the objects and can release them, but the second one is directly in our code.

The thing is, as soon as Entity Framework context goes out of scope, it should release it’s memory -it’s all managed, and IDispose juste releases the memory deterministically.

Now the fun part, with IOC and DI containers, we tend to receive our references and the container itself manages the lifetime. So if our container is badly configured, we depend on the container to release objects (so they can garbage collected) and just lost the ability to get garbage collection based on out of scope…

DI containers are fun and fancy, and a real plus when you are testing, but PLEASE ensure they are configured correctly !

The first memory leak was hosted on premise with IT people who had no idea how to take a memory snapshot, that was hard.

Azure on the other hand, has all of this stuff built-in, i was completely blown away at how much diagnostic tools were build into the plateform. It’s called “Diagnostics as a Service”. Go discover it !


SQL Dynamic Data Masking

When working with database, we sometimes have to backup-restore them in order to bring them to a test environments. When this happens on premise, there is a good chance the backup gets restored to a know machine.

With the cloud and outsourcing, the backup could be restored miles away on another continent.

Go read this : SQL Azure Data Masking

Ok, the concept is easy enough to grasp, but it is based on the fact that you login with one or another user. Most web applications use a generic user to connect to the database and implement application level security, not at the database layer.

Who knows how we can keep using application security, but pass a special token or something when we need to read the actual data ?

Is there a way to apply the dynamic masking within the database at time of backup so people getting a copy of it gets a safe copy ?

There are two use cases, the first is scrambling data. The second is just not showing it all (i.e. a Er** instead of Erik). Do the where clauses apply to the real value or the mask ?

 

Great things with this technology, i just have to start testing it out…


SQL Azure Sizing

Well, one of my teams just went to production with a rather big project. The whole thing is on hosted on Microsoft Azure.

Like all projects, you always learn a couple of things, there are always good things, bad things and things that could of been done better.

For this project, we chose the Azure SQL Databases to hold the data. An S0 instance gives us plenty of space, and since we actually spent time benchmarking the system, ou sql queries were optimised and we had caching where it counted. I thought we were pretty good and the there would have to be a massive amount of concurrent users on the system to kill it…

Turns out all you need is 60, because although a S0 can take a lot of parallel inserts at a time, it can only handle 60 connections at a time. That is a real bummer.

The chances that we hit 60 connections at the same moment is still pretty slim, because connections are only open for the lifetime of a request. Still, i brought our system up to S1 which gives us 90 connections, just in case…

Another fun thing is we implemented in EF the required SQL error retry logic, so if we get denied because of no available connections, the system will simply retry after a certain timeout, that should prevent the code from failing at the expense of longer execution time.

I though i understood the whole DTU thing, but never took into account the connection limit.. Oh well, live and learn

Refer to this page for information of these limits.


Power BI wowness !

I am sitting in a meeting where i am looking at beautifu PowerBI dashbaords built on top of a system we built that is going live soon.

The architecture we had planned called for using PowerBI, but didn`t just how good it is.

The best part, there is a whole gallery of custom visualisations (https://app.powerbi.com/visuals/) for those times you want to express something that wasn’t included inside the box.

Lastly, how did we get the data into PowerBI ? EntityFramework +Restier + Odata ! If the Power BI team is listening, let us  do custom data sources !