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

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

Macro in Excel not working after update

I am using an Excel 2013 sheet to create invoices. It is powered by macro’s a lot. After the latest Office updates the Excel sheet did not work like it use to. It reported unclear errors.

After some searching on the internet I found the solution to this situation. Just search for file MSForms.exd, which shall be located in temporary folder C:\Users\user.name\AppData\Local\Temp\Excel8.0\ and delete MSForms.exd. The file will be rebuild during the next Excel 2013 launch, and all VBA macros will work.

It worked and so did my Invoice sheet.

Posted in dotnetmag, Microsoft Office 2013, Tip | Comments Off

ConnectionStrings / AppSettings Azure

During my actions to understand Azure webjobs I stumbled upon this nice feature.

A Webjob is deployed with an Azure website. With a Webjob there belongs a dashboard for logging and details on processing. After I deployed my Webjob on this Dashboard I saw errors and warnings. Although my Webjob was running according to the status.

 siteconstring1

As the error/warning told, I had to add the Connectionstring to the connectionstrings part on the configure part of an Azure website. That cleared the error/warning.

siteconstring2

First thought was now I have to configure the Connectionstring on two places. Once on the portal and once in the app.config of the Webjob. This is not I would like it. I don’t like a setting configured on two places. But that is not necessary.

In your code you use:
var storageAccount =
       CloudStorageAccount.Parse(
          ConfigurationManager.
              ConnectionStrings[
“AzureWebJobsStorage”].
                  ConnectionString
       );

But the value of the Connectionstrings or App settings are entered on the Configure tab of the Azure Website.

image

And this also works for the App.config of an Azure Webjob.

More information: http://www.asp.net/identity/overview/features-api/best-practices-for-deploying-passwords-and-other-sensitive-data-to-aspnet-and-azure

Posted in Azure, Cloud, DevOps, dotnetmag | Comments Off

Microsoft Azure: Linux

During the past Connect(); event in New York Microsoft made clear they love Linux and Open Source. Their .NET framework is now open source which shows this love. But Satya Nadella earlier already stated Microsoft Love Linux.

Microsoft_LOVES_Linux

In the beginning Azure only exists of Microsoft related products. In fact Azure was only PAAS. Virtual Machines like with Amazon wasn’t possible. There has been something called VM Role but luckily this was replaced very quickly by the real IAAS.

Since the new HTML portal (http://manage.windowsazure.com) IAAS or Virtual Machine belong to Microsoft Cloud landscape. And Linux images belonged to them on day one! Many frowned their eyebrows, the number of images just went up. On the current preview Portal (http://portal.azure.com) the list of Linux images is really big. And I think it is not the end yet. Perhaps in the Marketplace other vendors will sell and service other Linux images. The bigger the demand, the bigger the offering.

11-23-2014 15-36-59

During my daily walk through the Azure portal (Microsoft Azure grows very quick) I saw I could service my own Minecraft server. The only thing you need, a name and 15 minutes. After that you got your own Minecraft server. How cool! This one runs on a Linux image by the way.

minecraftazure

What is your reason not to use Microsoft Azure?

Posted in Azure, Cloud, DevOps, dotnetmag | Comments Off

Visual Studio 2015 Preview: C# 6

On November 12 and 13 Microsoft organized the Connect(); event in New York. the keynote was live and the Dutch communities (WAZUG, DotNed, VB Central and of course SDN) had organized a evening event to watch the keynote together. If you weren’t there or missed the event completely, you can still watch via Channel 9. Not the least speakers were there: Scott Guthrie, S. Somasegar, Brian Harry and Scott Hanselman.

During this event Microsoft showed the words of CEO Satya Nadella, Mobile First, Cloud First, weren’t just a hollow remark. The statement is part of whole Microsoft and in all the do. The keynote showed it.

They did a lot of announcements, one was the fact Microsoft made the .NET platform Open Source via GitHUB. Which means anyone can do a Pull request and solve bugs etc. Microsoft will pick up these changes (after testing etc.) corporate in the branch. How cool is that! The first pull request came within a hour after opening.

An other announcement was a preview of Visual Studio 2015. Besides that also new previews of ASP vNext and C# 6. However there are no new language elements added, but the language and tooling is cleaned and optimized. All adjustments are meant to make it easier for the developer.

In this blogpost a few of the changes.

Code must besides easier to read also cleaner. Take this simple method, we could do without the function body.

11-22-2014 15-57-00

By using the Lambda arrow (=>) it is possible to make it shorter. The Lambda arrow was already in the language, but now you can use it for this too. There is an other usage.

11-22-2014 15-57-00

Clean code, understandable and readable. Self documenting code Knipogende emoticon

Other change. You will recognize the next code construction.

11-22-2014 16-00-57

With the new Elvis operator it can be shorter and more readable. The ?. (image some Elvis hair and eyes) operator checks for the object to be NULL.

11-22-2014 16-01-07

Also posisble with methods in a Class: x?.Calc(1,2); Personally I find this dangerous, because the Calc methode is not executed if x is NULL. And if your tests or structure of the application is not good, this will unpredictable situations.

Another construction you and I use a lot. We make strings for messages and we use of course the string.Format method. Super easy and rather readable, disadvantage you need to count the position and it is not always clear in a blink of an eye.

11-22-2014 16-03-39

So this should be different. Simple \{<variable>} and the code is more documented. Of course the formatting rules of string.Format are still possible, complete freedom for the text.

11-22-2014 16-03-39

The above line makes the variable a field of a class/object. By making it public, you can manipulate it. You better use properties. But nowadays properties need to have a getter and a setter. In C# 6 there is the notion of a read-only property, a property with a getter and no setter.

This in the above example done with the lambda arrow, it will transfer in a read-only property automatically. You see this by the Code lens reference counter. But if you want to change the property in code you get a compiler warning.

11-22-2014 16-04-47

11-22-2014 16-01-54

There are lots more, more about that later.

Posted in dotnetmag, Tip, Visual Studio, vNext | Comments Off

Windows 10 Technical Preview

Since this week Windows 10 is available in a Technical Preview. This version is not for faint harted or inexperience users. Other advice is not to install it on your main computer.

So I did download it and installed it on my Surface Pro 3. I choose not to upgrade my existing version of Windows 8.1. As a result I missed an awful lot of drivers ;-) Luckily I could download them on another laptop. 

10-8-2014 12-37-21 10-8-2014 12-37-42

In the near future there will be a real beta for everyone. This version just scratches the surface on all coming changes.

What did change? If you are still using Windows 7, you probably look at Windows 8 on occasions and found the Startmenu is not there. Well not completely true, in fact your Start menu is now a complete screen. But when using Windows 8 for the first time, it is difficult to use. It looks like they moved all the cheese around.

Windows 8 was built for tablets or laptops/desktops with touch. Windows 7 was perfectly usable with a mouse and keyboard. In fact Windows could be used with just a keyboard. With Windows 8 (and with the introduction of the Surface RT) Touch came as a new dimension.

If you used a Metro or Windows 8 app from the Store, you had to swipe from the right to get to the settings of the app. There Charms bar with the settings of the active app became visible. With the mouse you had to go to the one pixel in the right upper corner of the screen. Or the key combination Windows-key + I of Windows-key + C(harms).

What was the problem? These ways of using Windows were not in our muscle memory and it felt very strange compared to the other versions.

With Windows 10 Microsoft is trying to solve this problem. Windows 8 was mainly made for touch/tablet, Windows 10 is built with the existing/normal desktop user without touch in mind.

And this Technical preview version feels good. Even on a tablet.

A quick tour. The most important change for many the start menu is back. But they tried to improve it too. The live tiles and the pinning capability like on the start screen are added.

Screenshot (5)

The search box is also back. In Windows 8.1 with the Windows-key + Q(uery) combination you could do a search. With this search option is it easier to search for apps. Clicking on ‘All Apps’ gives you the same experience as in Windows 7. You will see the folders of installed x86 apps not from the Windows Store.

On the Taskbar is also a magnifier. With this you can perform a desktop search. But the addition it does not only search for files of apps, but also gives search results from search engines. Which can be pretty handy.

The startmenu can be adjusted in height and width, interessting for a 4K Monitor.

Back to the Windows 8.1 way of working? Also possible. According to some clips on the internet switching between a Start menu and a Start page will be automatic when detaching the keyboard on a Surface. That would be logical and a real handy.

On the taskbar perform a right mouse click and go to properties. On the third tab ‘Start Menu’ change the setting. It will be affective after logging in again.

Screenshot (9) Screenshot (10) 

The Windows key and hardware button show you the Start screen again.

Screenshot (13)  

Another design thingy all windows now have some sort of halo/shadow. The picture below does not show it clearly, but it is funny.

Screenshot (11)

The change which is only noteable when comparing it to Windows 8, all windows now don’t have an edge. The screens below show this, on top Windows 8 and on below Windows 10. It makes it easier for the eyes.

10-8-2014 13-45-13 10-8-2014 13-45-43

Of course the icons are also changed and refreshed. And they cleaned up some useless spacing.

In Windows 8 a Store app / Metro app / Windows 8 app was always full screen. Not anymore, they are now filling up the screen. But you can change the size.

Screenshot (6)Screenshot (7)

The necessity to go to the Charms bar is removed. In the title bar there is a button with three dots (…). With this menu you can go to the settings. That is logic, because an app is not anymore full screen.

The resizing of a Store app is limited to the height. At this moment (?) there is a minimal height for a Windows Store app, the width is not yet is less limited.

In all versions of Windows ALT-TAB is the way to flip through the open apps. The Windows key–TAB was added and the opened applications was show more graphical manner. In Windows 8 this worked too, but the Windows Store apps were not shown. Now they do.

Screenshot (3)

Other news in the black bar ‘Add a Desktop’ is shown. In Windows 10 you can have multiple desktops. On one physical screen you can split your apps and desktops.

Screenshot (1)

In Windows 7/8 desktop with the key combination Windows key+arrow right/left, the active application could be docked to the left of right. Handy to read two documents next to each other. There are just a few possible ways: left, right, full screen, normal.

In Windows 8 metro there were no key combinations and less possibilities. At first there two Windows Store apps side by side and in 8.1 it was changed to 3.

In Windows 10 the screen is divided in 4 quadrants and with the Windows key and the arrows. This is also possible for Windows Store apps, with respect of the minimal height.

Screenshot (4)

The last part of Windows not changed for a very long time; the command prompt. A modern environment but not modern Command prompt. But now the Command prompt is really changed.

Cut/Copy/Paste is now possible with the well-known keystrokes. Selecting of text on the screen is possible. You can make the prompt transparent. Lots of little things we already wanted for decades.

 10-8-2014 13-55-32 10-8-2014 13-56-04 10-8-2014 14-01-21      

We are talking about a Technical Preview, but it feels very stable. The many changes look very good. It is not the end, because some functionality is broken. ALT-F4 does not work for Windows Store apps at this moment. On my Tablet/Laptop Surface it feels very good and natural.

Disclaimer: This post is based on a preview and all items are subject to change in the future.

I love to see the next updates. During the Build conference in April more details and probably a public beta will come.

Posted in dotnetmag, Surface, Windows 10, Windows 8 | Leave a comment

IoT (2) Intel Galileo

At the last //Build conference they spoke about Windows on a Intel mainboard. Intel developed a chip which was capable of running Microsoft Windows. The board is a Intel Galileo. In fact it is a Arduino board so the available Arduino components (of which a lot is available) can be used with it.

The Arduino development environment is shown below. The code is C / C++. The example will make the onboard led blink.

30-8-2014 19-20-31

I wanted Windows on it of course. Therefore I had to perform a firmware update. The Arduino development environment is fairly simple. It is copy/paste of a directory with everything in it. It also contains the Firmware update.

19-8-2014 22-23-47 

To get Windows for the Galileo board, you need Microsoft Connect access to the Windows Embedded Pre-release program. Via these pages on GitHub they tell you the steps to install.

Below the process of installing on the SD card.

19-8-2014 21-15-34

WP_20140830_005 - Copy

When ready you need to place the card on the  Galileo board. The Galileo watcher app will show him (if it is connected via USB/Ethernet).

30-8-2014 13-26-08

There is a little Webserver with this Windows too.

30-8-2014 13-25-48

You can create a network share and it will show you the files.

30-8-2014 13-26-58

The directory of the web server. I have changes some text here.

30-8-2014 13-30-57

The directory where the deployments will be done.

30-8-2014 13-27-17

Ok, now we have Windows on it. Lets build something. For .NET Gadgeteer was it simple. With this it will be a little different. There is a Visual Studio 2013 project template for C++.

30-8-2014 13-35-50

For this demo I did not use the onboard led, but I added a led to the board. Via code I will make it blink.

30-8-2014 13-39-06

Does not look difficult. And if you run and debug it, it will show in je Visual Studio.

30-8-2014 13-39-16      

And the led will blink. The red led on the second picture is brighter.

WP_20140830_006WP_20140830_007

But lets take it a step further. I also bought a 16×2 display for showing texts.

30-8-2014 13-29-40  

Connecting it is less elegant than with the .NET Gadgeteer platform. You need a breadboard and lots of cables to make connections.

 WP_20140830_003    

But the result of the code is visible. On the screen i++ iterates.

Cool he. I need to experiment more with it. There is a lot of things possible. Although I have to refresh my C++.

Posted in dotnetmag, Gadget, Gadgets | Leave a comment

IoT (1) .NET Gadgeteer

Internet of Things has gain interest over the pas months/years. Not that strange, because the world is becoming more connected everyday. Everything and everyone is connected on every spot on this globe. On vacation in the early days you send postcards to the ones left behind. A vacation was getting away for real. For a long time there were no Dutch newspapers in foreign countries, so news from the home country was also blocked during the vacation.

But now everyone has a mobile and tablets. Almost everywhere we have internet and we keep each other posted over the internet via Twitter, FaceBook, mail or other media.

Not only humans are more connected, even devices are connected. Most cars have a button to call the garage if there are problems. Your mobile is connected to a satellite for its location. This will expand over time. We already have a lot of sensors in our house to automatically heat or cool down our homes. With current home automation we can control from a distant our lamps in house. Our refrigerators will get sensors and put a order if the stock is low. Smart watches will check your heart and your health. Perhaps in the future it will contact a ambulance or a doctor based on spikes in your measurements. Lots of other applications will come.

All those things have to be programmed. Previous we used electronic circuits etc and low level programming languages. But nowadays we want to do it more easier. If possible with languages we already use. It will make it cheaper in the end.

There is something like .NET Gadgeteer. This is a set of modules and a motherboard to create and try out an idea. This is programmed with the .NET Microsoft Framework and makes use of Visual Studio 2010.

WP_20140830_011

The designer is very WYSIWYG. You drag a component on the canvas and clicks on connect, it will show how to connect the component to the motherboard.

30-8-2014 17-31-39

In code via intellisense you get the methods on the component. Everything is done with C#, so pretty comfy. You can deploy it and run it on the motherboard.

30-8-2014 17-32-30 

Also debugging and trying your solution.

 WP_20140830_010

The .NET Micro Framework is very old. The successor is Windows Embedded. It needs different hardware. Hardware which runs Windows in some form.

In my next blog post I will tell about the Intel Galileo motherboard which runs Windows.

Posted in dotnetmag, Gadget, Gadgets, Visual Studio | Leave a comment

Bing while coding

Every developer does it, during developing you search the for tips and tricks. In the last couple of years the number of resources on the internet is grown. Help, tips and code example can be found on many forums, MSDN, CodeProjectStackOverflow and many many other places. It is impossible to know them all or to have them in a list or so. So we use our favorite search engine get the help we need. We have to leave the comfort of Visual Studio. You start a browser browser and search. Since a few weeks there is a handy extension for Visual Studio available. With this you can stay in your development environment.

30-8-2014 14-27-33

Do yo have to something special during coding? Nope, it works automatically. You start typing your code and the intellisense kicks in (or press ALT+space). The results of the intellisense are extended with Bing search results.

 28-8-2014 06-57-38

How handy! So besides the standard documentation you see the code examples from the community.

If this still not gives enough information or you need to start a different kind of search, in de menubar a searchbox added. Type hre your question and in your Visual Studio the results will show in a handy and clear view.

 28-8-2014 06-58-43

 28-8-2014 06-58-53

28-8-2014 06-59-03 

Not everyone has full internet during work. Demo and code examples can be placed on a local location and it will serve as source for the Bing Visual Studio tool.

30-8-2014 15-36-07

How handy! In this way you don’t need to switch context during coding. You can stay in the flow.

Happy coding!

Posted in dotnetmag, Tip, Visual Studio | Leave a comment