.NET on Raspberry PI 2

In a previous blogpost I told about Windows 10 IoT Core. This is great, because you can program in C# and you can add a Graphical user interface to it. But most of the IoT devices will not need user interaction or attached to a Monitor. The most IoT devices collect data and give that to others or keep track of an environment and are only expecting control information.

There may be enough reasons to use Windows 10 IoT Core, but it is not necessary for a Microsoft environment. Also on NOOBS (New Out of the Box Software) OS you definitely can use .NET.

For a couple of years the Mono project is going on and there lies the key of multi platform.

On your Raspberry PI 2 you can do: sudo apt-get install Mono-complete. With that you get Mono installed on your Raspberry.

The powerful Owin makes it possible to host a ASP.NET website on it.

6-14-2015 12-45-22 PM

The result:

6-14-2015 12-23-21 PM

Besides a website you can also host WebApi.

6-14-2015 12-46-19 PM

The result:

6-14-2015 12-44-29 PM

Pretty handy. I also have an example where a Raspberry PI 2 puts data on an Azure Storage queue. Because there is more on this, I will get back to that at a later moment.

Posted in dotnetmag, Gadget, Gadgets, IoT, Tip | Comments Off on .NET on Raspberry PI 2

Project Oxford

During the //Build/ Conference they showed a very nice demo; the Photo site (http://how-old.net/).

image

Project Oxford (http://www.projectoxford.ai/) is the base of this app. This API offers a lot of possibilities. The best part, you can use it yourself.

image

There is a fully documented API available. These API’s are for free for now, but it is a lot of fun to play with it.

image

Azure Machine Learning is used for the learning of the API. There is a nice free e-book about Machine Learning. Very readable and gives you some basis knowledge of Machine learning.

During the last Ignite Conference there was a second keynote. Done by the Technology and Research department of Microsoft. They showed what they did the past years. Like PowerBI and the translation machine of Skype etc. There was a funny demo about Data analyze and historical data.

When you are in Big Data or likes it, then I suggest you watch the second keynote (Ignite KEY02   The Next Era of Computing: Seeing the Future Before It Happens).

During a IoT Hackaton we connected a Raspberry PI 2 to a camera the photo’s were passed through this API. It worked. Unfortunately we could not use Windows 10 IoT Core yet.

Posted in dotnetmag, Gadget, Gadgets, IoT, Tip | Comments Off on Project Oxford

Windows 10 Development: Small and Big Screens

With Windows 10 and the fact that it runs on every device, the Universal app as we know in Windows 8.1 is gone. That makes it easier, but also more complex in another way.

image image

Previous you had a project for Windows Phone and the windows in this project are for small screens. Now every size of window is in one project even in one XAML file, you have to deal with that in one way.

Lucky the Windows 10 development SDK has some useful resources. Like a RelativePanel. On a RelativePanel the controls have a relative position to other controls. Way better than before, where you had to play with margins and absolute positions. Which let to strange behavior on different screen sizes etc.

image

Another powerful one is SplitView, then you have a Content and a Pane part. Most of the time we have a master detail on a window.

image

But this is not helpful if manipulation is done by coding stuff in events in the Code behind. Because that is not the way to do it anymore in a XAML / MVVM world. There is a nice solution for.

The VisualStateManager, which contains VisualStates with StateTrigger and StateSetters.

image

From a VisualState you set what the MinimalWidth or Height should be and with the Setters you specify what will happen.

image

In my SDN evaluation app example it looks like this. With the first the minimal width is 720 and from the second the alternative. This will also work on a Windows Phone with Windows 10, where you hold the phone in landscape or portrait.

image  image

As you noticed I have added a hamburger menu, I think a control would be better. It is a toggle button with the Font (Segoe MDL2 Assets) and a Glyph.

image

It works nice, but I hope they make it a bit better.

Nice session on Ignite: BRK2310 From the Small Screen to the Big Screen: Building Universal App Experiences with XAML

(disclaimer I am no XAML expert, I know a little)

Posted in dotnetmag, Visual Studio, Windows 10 | Comments Off on Windows 10 Development: Small and Big Screens

Windows 10 IoT Core

Since the //Build/ conference is a technical preview of Windows 10 for Raspberry PI 2 is available. With that the promise of Microsoft (Windows on all devices) becomes reality.

There will be 3 versions of Windows 10 IoT available: For Industry Devices, Mobile Devices and Core. Installing Windows 10 IoT Core on a Raspberry PI 2 very easy.

More information on http://windowsondevices.com and demos http://ms-iot.github.io/content/win10/StartCoding.htm.

win10_core_01

While installing you will see these screens pass by. The first startup of Windows 10 IoT Core takes a bit longer, some additional setups are being done. No worries next time the startup is fairly fast.

WP_20150516_17_33_01_ProWP_20150516_17_33_21_ProWP_20150516_17_35_13_Pro

When finished you see this.

win10_core_02

In this early version some functions are not ready yet, but that will change soon.

On a Windows 10 machine with Visual Studio 2015 you can make a ‘normal’ Windows Universal App. This app can be deployed to your Raspberry PI 2 and the standard debug/F5 experience will just work.

 win10_core_03

In the IoT makers world a lot of components are available and most will work on the Raspberry PI 2 with Windows 10 IoT Core too. Have a look at the examples on http://windowsondevices.com.

WP_20150522_11_21_17_ProWP_20150522_11_25_41_Pro

I have ordered some components and soon I will post more on these experiments. This is fun Knipogende emoticon!

Posted in dotnetmag, Gadget, Gadgets, IoT, Visual Studio, Windows 10 | Comments Off on Windows 10 IoT Core

Consume Modern SaaS EndPoints with Visual Studio 2015

We all know the functionality of Visual Studio to add a Service reference to your project. With this you can consume available Services rather easy in your application. From the code you can get to the methods of the services rather easy etc. More information can be found here.

Service Reference is a burden if the service needs credentials. The credentials with which you create the reference are often not the credentials you use in your application. Sometimes more configuration is needed and you need to read the documentation to find out. Can be done via the configuration files, but not fairly easy without good documentation.

Sometimes you need additional components or libraries while using a Service Reference. In Visual Studio we have NuGet to accomplish this. NuGet is anonymous and very generic; as provider of the component you can provide it to others, but configuration wise there is again without documentation nothing to support or help.

You need a combination of both.

In VS2015 they have added Connected Services. With Connected Services you will be helped with a Wizard to fill the correct parameters and adding the correct components to your project.

For now the number of Connected Services is not big yet, but App Insight, Mobile Services, Storage and SalesForce are available.

It is a open system. Everyone can add their own connected services and provide the to everybody. You can create your own Wizard to support your users.

connectedservices

Nice right? At Ignite there was a nice session BRK3706, which can be viewed via Channel 9 (https://channel9.msdn.com/Events/Ignite/2015/BRK3706).

Posted in dotnetmag, Tip, Visual Studio | Comments Off on Consume Modern SaaS EndPoints with Visual Studio 2015

Xamarin: Multi Platform Development

In the past I wrote some applications for the Windows Phone Platform. A few of them can be even found in the store. They are not perfect, but they gave me good insight in how it works. What does a little screen mean for development and what does it need to get in the store?

image

The first of the list is still in the store, but I lost the code Knipogende emoticon. Even then the rules of the store are tighten a lot, so this app would not stand these current rules.

I have a app for the Windows 8 platform too. Well in fact a few more, but they are not available for download. One is a demo app for Azure Mobile Services and one is the SDN evaluation app I talked about previously.

image

http://apps.microsoft.com/windows/en-us/app/three-of-a-kind/a5ab2f2a-c42d-45de-95c6-13a10e5b1256

But anyway, I wanted to make an app for Android and iOS too. I have tried on my iMac with Xcode, but I got lost in Objective C language and could not find my way with the Apple tools. In the Microsoft world Xamarin is the environment to do it. A super tool to exploit your current skills for the other platforms.

I had this need to develop for the other platforms for some time, but could not find the time. But I found time. It is a kind of Hello World app, although the usage is bigger. But almost no shared code and no server side code.

At my former employer Ronald Hubert made a Scrum app for Windows Phone. I have used his idea and design of the cards. I did not reuse his code and wrote it myself.

You make two windows, draws the cards on the first and in the Click event you open the second window. In the second window you load the correct scrum card with a Click event to get back to the first window.

In code:

private void imageV_Tapped(object sender, TappedRoutedEventArgs e)
{     Frame.Navigate(typeof(DetailPage), "V");
}

So in the Click event of the image, tell where to navigate to with a parameter. Clean and simple Knipogende emoticon

wp8

For Android development you have two choices. Or you develop with Visual Studio or you develop with Xamarin Studio. The first is more the way you always work as a C# developer. I haven chosen to work with Xamarin Studio.

In fact the same ritual like Windows Phone is used.

ImageButton imButton1 = FindViewById<ImageButton> (Resource.Id.imageButton1);
imButton1.Click += new EventHandler (PictureBtn_Click);
void PictureBtn_Click(Object sender, EventArgs e)
{
	ImageButton imgbut = (ImageButton)sender;
 
	var intent = new Intent (this, typeof (NextScreenActivity));
	intent.PutExtra ("picture", (imgbut.Tag == null ? "" : imgbut.Tag.ToString()));
	StartActivity (intent);
}

Different is, you need to find the button on screen (like in HTML) and connect to an event. In the event a new Intent created and with the Intent an Activity must be started.

nadroidvs

androidxs

Apple/iOS uses a Story board and forces MVC. There lot’s of events and codeblocks for the iOS part.

image

Screen Shot 2015-02-14 at 13.37.40

Although I could use C#, it was three time different developments.

There is also something like Xamarin Forms. Then the frontend for the different operating systems will be more alike. That will be my next project.

To get the apps in de Stores wasn’t that easy like before. Windows Phone and Android were much alike, but the Apple appstore was more trouble and takes more time to be validated.

To download this app::

Posted in dotnetmag, Gadget, Windows Phone | Comments Off on Xamarin: Multi Platform Development

Windows 10 and Office Apps

Since some weeks I am running the newest Windows 10 Technical Preview on my Surface Pro 3. The first version of Windows 10 was getting the worst behaviors of Windows 8.1 out of the system. Windows 8 was very Touch oriented, the first Technical preview of Windows 10 was more oriented on keyboard and mouse. This new version combines them better.

Some other new and nice additions are Cortana and Continuum. We know the first from the telephone and in same way from the XBox. You can speak to your PC in a natural language and she will understand you. Not like the old days where the computers had a small vocabulary. On the Phone and now on the PC you can activate Cortana by saying ‘Hey Cortana’. (At this moment only available in some countries)

During the first presentation of the Windows 8 successor they showed a slow movie about Continuum. Removing a keyboard will be detected and gives you the possibility to go into tablet mode.

10-2-2015 01-41-26

I have played with it and it works pretty nice. Even if you put the Type cover on a Surface to the back, it detects it as removing the keyboard. Now they should implement it detects a dockingstation too, because then you probably will stay out of tablet mode. One annoying thing when going into Tablet mode the desktop is not available anymore. Documents, shortcuts, apps etc on the desktop cannot be moved/executed or changed in Tablet mode.

Also the startmenu freshed up. On the left hand side the list with all applications is ordered and sorted. Grouping is possible again like we did on the Start screen.

Screenshot (4)

In de first version the icons were changed a little, they have changed more of them.

Screenshot (5)

Screenshot (6)

New in this version, Windows Store apps have more buttons on the title bar. On the right side there are Close, Full screen, maximize and minimize. On the left there is a little menu, with the items of Windows 8 with a Swipe from the right. They had to do this, because the store apps are now running in their own Window.

Screenshot (7)

This will not be the last changes, many will follow in the way to Build and during Build.

There is a new Touch based version of Office available. On all mobile platforms like Android, Apple and Windows Phone we had nice mobile versions of Office. The Android and Apple versions were a little further than on the Microsoft platform itself. But now in Windows 10 a preview of Word, Excel and PowerPoint is available. These have to be installed and downloaded from the store.

10-2-2015 01-34-51

They are rather complete and look very tight and nice.

10-2-2015 01-36-46

New documents will be placed by default on your OneDrive. Very handy, this makes your documents available on all your devices. This makes collaborate with others very easy. In each of the Office products there is a “Collaborate with others” button. Your document on OneDrive will be shared with the person you want to collaborate.

Screenshot (2)

Changes can be seen real time.

PowerPoint is for presentation of course. But like every App store app, it is Windowed so not full screen. Like you used too.

Screenshot (3)

I need some time during real presentations to get acquainted with this. Strange is though, the new menu items and buttons on the Title bar are not there with Office apps. Which I did not expect.

This version of Windows 10 is leaner and meaner, but there are still some rough edges. The Office apps are a real nice addition.

Posted in dotnetmag, Gadget, Gadgets, Office365, Surface, Windows 10 | Comments Off on Windows 10 and Office Apps

IoT (3) Intel Galileo

In my last blog I already told about Microsoft Windows on a Intel Galileo board.  I showed how to show some texts on a LCD display with C++ code. Not long after that the second generation of the Galileo board came. It was a little more powerful.

In my last blog I had to connect my LCD display via a breadboard to my Galileo. Not uncommon in the Arduino world, but it doesn’t look nice and is very error-prone for not very technical people. So I bought a Seeed Grove Starter Kit. Another advantage of this kit it contains different sensors etc. Very nice to start something.

So why this new post then? This time I did not want to just lid a LED or show some text on a display. But I wanted to combine some stuff. A led on port 13, a LED socket on port 7, a button on port 3 and a LCD display.

The single led blinked permanently, but the other should lid up when you push the button and the display shows that too.

First I did it again in the Arduino environment. On the Galileo there is noting special needed.

iot

He, that is no fun. Windows can be run on this thing, so I had to use that. So move the code from Arduino to a Visual Studio solution. Include the rgb_lcd.h header file and compile. “Rebuild All succeeded”.

vs

Then start the Remote Debugger.

image

And we break in the first breakpoint.

WP_20150211_22_04_36_Pro

WP_20150211_22_01_18_Pro

Before debugging the application is deployed and copied to the Galileo. On the C-disk (the SD card) is a directory Test with the executable. By using telnet you can start the executable. Like you see below, and it stays running till you stop it. Of course there a possibilities to let it start after starting the Galileo.

WP_20150211_001

Next challenge is waiting for the next version of Windows for Galileo, Windows 10. I hope with support for .NET / C#. I am very curious how the many Arduino modules will be available via C#. Microsoft also announced Windows 10 support for Raspberry PI. I bought one, so I will play with it.

At Xpirit and Xebia started a IoT Makers lab. Together with colleagues we are making and designing nice IoT solutions. I will get back on that later!

Posted in dotnetmag, Gadget, Gadgets, IoT, Visual Studio, Windows 10 | Comments Off on IoT (3) Intel Galileo

API Management

It is for vendors of products very difficult to make mobile applications for every possible mobile platform. Of course by preparing and making a good responsive mobile website available will enhance your reach. Not getting the most out of the mobile devices is the downside of a mobile website.

Because of this vendors make their back-office via API’s available to the world. As a vendor you want earn some money on the usage of your API. This means you need a Developer portal where you can divide developers in groups, generate help pages, provide demo/example code, monitoring of the usage, place to get issues, FAQ, but also block or blacklist certain developers/users/applications. In short there is more needed then simple provide some webservices.

A while ago I had such a dream too. I wanted to create an evaluation app for the SDN. Attendees of a SDN event should be able to fill in a evaluation form via their mobile devices. The evaluation was stored on Azure in a datastore. Of course I did not want to store my tokens/connectionstrings/passwords etc with my mobile app. And I am not able to create a app for every platform, so I definitely did not want to share my secrets with some unknown/wild developers.

Screenshot (1)_thumb

So I thought of preparing some Webapi services and expose them. But like I described above, I needed a portal to explain my services and their responses. That is a lot of work for a small API like this. This is my portal now; http://sdnevalapp.azurewebsites.net/.

1-7-2015 4-34-32 PM_thumb[2]

Luckily there is a solution on the Azure platform. The API management service (documentation site).

1-7-2015 4-40-33 PM_thumb[1]

1-5-2015 9-53-21 AM_thumb[4]

After creating the service, there is a different portal (https://marcelmeijer.portal.azure-api.net/admin) to do the settings, looking at the metrics, the applications, the usage etc.

1-5-2015 9-53-33 AM_thumb[2]

At the settings is the place to make the webservices available. The different operations, HTTP actions, the response codes, which URL, description and informational texts.

1-5-2015 9-56-59 AM_thumb[4]

1-5-2015 9-57-15 AM_thumb[2]

The URL to the source services can also be hosted on-premises. Of course it is smart and wise to secure the endpoints on this URL with Certificates, UserName/Password combination or with OAuth.

This was the management portal for the admin of the API(https://marcelmeijer.portal.azure-api.net/admin), for the developers there is a separate portal (https://marcelmeijer.portal.azure-api.net/). Which can be styled and changed within limits.

This Developer portal is rather complete. All the mentioned functionality can be found on it.

1-5-2015 9-53-44 AM_thumb[1]

There is a handy overview of the available API’s.

1-5-2015 9-53-59 AM_thumb[2]

From the available API you can see the endpoints. You see the descriptions and the URI for calling the endpoint. To use the endpoint in an application the addition of a subscription key. The whole idea of this portal is to regulate usage and with these subscription key is bound per API to an application/developer. Because the base endpoints are secured by Certificaten, Username/Passwords or with OAuth, bypassing the API management is useless.

On this Developer portal there is even a possibility to try out the API method for the different HTTP actions. The trace and the result is shown.

1-5-2015 9-54-38 AM_thumb[1]

1-5-2015 9-54-56 AM_thumb[2]

1-5-2015 9-55-30 AM_thumb[1]

At the bottom of the page you can find example code for a lot of programming languages. Everything to help your ‘customers’ of your API.

1-5-2015 9-55-45 AM_thumb[1]

As I told in the beginning of this blog, making an API available is one thing, but document/manage it is another thing. By using the Azure service you can focus on the fun and most important part of the API, the functionality.

Why develop it yourself, when you can use the expertise of others. “You can reach further while standing on the shoulders of giants”

Posted in Azure, Cloud, dotnetmag | Comments Off on API Management

Azure Webjobs

During the past Dutch Microsoft Techdays 2014 I did a session about Azure Cloud Services. A recording (in Dutch) can be found on Channel 9. In the beginning of Azure, Cloud services were the “way to go”.

Cloud Services is a very powerful concept, but it had some small cons. Existing applications could not moved to the Cloud via a Lift and Shift method. Mostly because the application wasn’t well designed itself. Most applications were not pure stateless, a-synchronic in base and most applications were not able to run in concurrent identical instances.

In the past years the Azure platform has become much richer with lots of different services. In stead of making something new or copying something from others, Microsoft takes existing products or tools makes it available/better suitable for Azure (like Hadoop, Docker, etc).

Also IT development itself became more mature. Developers and architects realize that Scale up doesn’t support availability, services/servers will break down and an internet application has the potency of a big audience.

Standard dogma’s like SOA architecture, Servicebusses or SOAP webservices are losing their power, Microservices looks more promising and are getting better tooling. About this I will blog in the near future.

Back to my Techdays demo. It looked something like this:

blog2_thumb[1]

The solution looked like this. The code can be downloaded or ask me. As said I exists of a WebRole and a WorkerRole. The WebRole is used for uploading and viewing the pictures.

webjob1_thumb

The flow of the application looked like this.

 Slide1_thumb[10] 

As you see besides uploading the WebRole has to add a message to a queue for the WorkerRole. The WorkerRole needed a mechanism to read the queue. Like I told in my session, you have to handle the Busy waiting problem. Reading from the queue is a transaction and a transaction costs money. An important part of the architecture on Azure is Cost Based design. So reading from for example a queue has to be efficient and effective with costs in mind.

Nowadays on Azure there is the possibility of Webjobs. With these webjobs it is possible to let it be triggered after a new blob is added to your storage. In my case this reduced the usage of a message on a queue and a own check on the queue in the WorkerRole. This part (checking new blobs on storage) is handled and controlled by the platform. And what I don’t have to do, save time and the platform can do this much more efficient. So the WorkerRole can be released by a Webjob. The WebRole can be replaced by an Azure Website. Did I need special skills for the WebRole, like reading the configuration settings. With an Azure Website I can use the technical skills I always used. And about the settings you can read about it in my previous blogpost.

The process looks like this.

 Slide2_thumb[7]

After a little redesign the website looks like.

blog3_thumb[1] 

The code of the Webjob is only this, some 55 lines of code.

function1_thumb[3]

The WorkerRole used double lines of code, of which the most was used for processing and not the real deal.

As I always tell during presentations, we can focus on the functionality and the real work, the rest is done by the Azure platform.

Ok, now the part of the web Client to get a message of the queue to see the job is done should be done otherwise.

NB In this blogpost I am not telling Cloud Services are useless. In the scenario above the extended possibilities of Cloud Services are not necessary. Look at this page for a detailed comparision.

Posted in Azure, Cloud, dotnetmag, Storage | Comments Off on Azure Webjobs