DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Integration Patterns in Microservices World
  • 6 of the Best API Testing Tools in the Market
  • Build Chatbots with Dialogflow - Step By Step Guidelines
  • Keep Your Application Secrets Secret

Trending

  • The Role of Functional Programming in Modern Software Development
  • SQL Server Index Optimization Strategies: Best Practices with Ola Hallengren’s Scripts
  • Rust and WebAssembly: Unlocking High-Performance Web Apps
  • Power BI Embedded Analytics — Part 2: Power BI Embedded Overview
  1. DZone
  2. Data Engineering
  3. Databases
  4. How to Install Mono on a Raspberry Pi

How to Install Mono on a Raspberry Pi

By 
Bruno Terkaly user avatar
Bruno Terkaly
·
Jun. 19, 14 · Interview
Likes (0)
Comment
Save
Tweet
Share
16.3K Views

Join the DZone community and get the full member experience.

Join For Free
  • This post exists to help with an MSDN Magazine article that I am authoring
  • It provides some of the low-level details for the article
    • How to install Mono and root certificates on a raspberry pi
    • How to create an Azure mobile service
    • How to create a Custom API inside Azure mobile services that the raspberry pi can call into
    • How to create an Azure storage account

MONO - HOW TO INSTALL ON A RASPBERRY PI

  • Why Mono?
  • How to install Mono on a raspberry pi
  • Installing trusted root certificates on to the raspberry pi
  • http://www.mono-project.com/Main_Page
  • An open source, cross-platform, implementation of C# and the CLR that is binary compatible with Microsoft.NET
  • Mono is a free and open source project led by Xamarin (formerly by Novell) that provides a .NET Framework-compatible set of tools including, among others, a C# compiler and a Common Language Runtime

WHY MONO?

  • Because it lets us write .net code compiled on Windows
  • We can simply copy the binary files from Windows to Linux and run it as is
  • From a raspberry pi device, it is possible to use a .net application to take a photo and upload it to Windows Azure storage

HOW TO INSTALL ON A RASPBERRY PI RUNNING LINUX

You will issue the following commands:

pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get install mono-complete

The first command makes sure all the local package index are up to date with the changes made in repositories. Second command installs the complete Mono tooling and runtime.

MAKING SURE THAT YOUR MONO APPLICATIONS CAN MAKE A HTTPS REST-BASED CALLS

This command downloads the trusted root certificates from the Mozilla LXR web site into the Mono certificate store. Once complete, the Raspberry PI will be capable of making web requests using HTTPS requests within Mono.

pi@raspberrypi ~ $ mozroots --import --ask-remove --machine

CREATING A NEW AZURE MOBILE SERVICES ACCOUNT

  • The mobile services account is needed to host a Node.js application that provides shared access signatures to raspberry pi devices
  • The shared access signature is needed by the raspberry pi, so that it can directly and securely upload photos to Azure storage

STEPS TO CREATE AN AZURE MOBILE SERVICE

  • The steps below will create an Azure mobile service
    • The service will be used to host a Node.js application interacting with a raspberry pi devices
    • We will provision a SQL database, although it will not be used initially

FOLLOW THESE STEPS TO CREATE THE MOBILE SERVICE

  • Login into the Azure Portal
  • Select MOBILE SERVICES from the left menu pane at the Azure Portal.
  • In the lower left corner select "+NEW" to create a new Azure Mobile Service.
  • Make sure you've selected, "COMPUTE / MOBILE SERVICE / CREATE."
  • You will now enter a url. We will call this service raspberrymobileservice.
  • For the DATABASE, we will choose "Create a new SQL database instance."
  • The REGION we chose is "West US."
  • The BACKEND is "JavaScript."
  • Click the "->" arrow to proceed to the next screen.
  • In this screen you will "Specify database settings."
  • The NAME of your database will based on the URL you entered previously.
  • In this case, the database is called "raspberrymobileservice_db."
  • You will need to choose a SERVER. We will choose "New SQL database server" from the drop-down list.
  • You will need to provide a SERVER LOGIN NAME and a SERVER LOGIN PASSWORD.
  • Take note of the login you provided as it will be needed later

CREATING A CUSTOM API

  • Azure mobile services allows you to create a custom API written in JavaScript that can be called from a raspberry pi device using REST
  • This custom API is really just a Node.js application running in the server

CREATING THE API TO RESPOND TO THE DEVICE TRYING TO UPLOAD PHOTOS

  • Now that the service is established, we will turn our attention to creating an API that the device can call into to upload a photo.
  • Login into the Azure Portal
  • Your mobile service will take a few minutes to complete, and you should see the "Ready" flag as the "Status" for your service.
  • Once it is ready you can drill into your service to customize its behavior. Just to the right of the service name, click the right arrow key "->" to drill into the service details.
    • The top menu bar will offer many options, but we are interested in the one titled "API."
    • The API allows you to create a series of node.JS API calls that a device can call into using rest-based approaches.
  • Click on "API." from there, select "CREATE A CUSTOM API." You will be asked to provide an API name. Type in "photos" for the API name.
  • Below you will see a series of drop-down combo boxes that relate to permission.
  • We will keep the default value of "Anybody with the application key."
    • This might not be the best option for all scenarios.
    • You can read more about this here. http://msdn.microsoft.com/en-us/library/azure/jj193161.aspx.
  • Click the checkmark to complete the process.
  • The name of the AP you just created, "Photos," should be visible on the portal interface.
  • To drill into the photos API click on the right arrow key "->". The right arrow key will be just to the right of the name of the API "Photos".
  • At this point you should see a basic script that has been provided by default. We will overwrite this default script with our own script as described in the MSDN Magazine article.

CREATING A STORAGE ACCOUNT TO STORE THE PHOTOS

  • Navigate to the portal and create a storage account
  • Create a container for the photos
  • Obtain the:
    • Storage Account Name (you will provide a name)
    • Storage Account Access key (generated for you)
    • Container Name (you will create)

CREATING A STORAGE ACCOUNT

  • We will need a storage account so that we can upload photos to it.
  • The steps are well documented here: http://azure.microsoft.com/en-us/documentation/articles/storage-create-storage-account/
  • In our case we call the storage account raspberrystorage.
    • This means that the URL that the device will use to upload photos is https://raspberrystorage.blob.core.windows.net/.
  • As you complete these steps make sure that you choose the storage account location to be the same location as was used for your mobile services account.
  • This avoids any unnecessary latency or bandwidth costs between data centers.
  • Once the storage account is created, we will need to create a container within it.
  • Photos or any blob for that matter, are always stored within a container. To create a container drill into your newly created storage account and select CONTAINERS from the top menu. From there, select CREATE A CONTAINER. The new container dialog box will ask for a name for your container. Take note of the name you provide. We are calling our container ?photocontainer.?

image001

  • When the raspberry pi device uploads photos to the storage account, it will target a specific container, such as the one we just created. You will next be asked to indicate ACCESS rights. To keep things simple we will select access rights of Public Blob.

ENTERING APP SETTINGS

  • Rather than hard-code storage account information inside your JavaScript/Node.js applications, you should consider using apps settings inside of the Azure mobile services portal
  • This post also discusses it well:
    • http://blogs.msdn.com/b/carlosfigueira/archive/2013/12/09/application-settings-in-azure-mobile-services.aspx
      • ?The idea of application settings is a set of key-value pairs which can be set for the mobile service (either via the portal or via the command-line interface), and those values could be then read in the service runtime.?

NAVIGATING TO APP SETTINGS

  • Navigate to the Azure Mobile Services section of the portal. Drill into the specific service by hitting the arrow below

image002

  • Select from the Configure Menu at the top

image003

  • Scroll down to the very bottom to see app settings

image004

  • Note that we need to enter: - We need to get this from Azure Storage - PhotoContainerName - AccountName - AccountKey
    • We get this information from the Azure Storage Section of the Portal. Note that you need to have provisioned a Storage Account to have this information.
    • How to get the AccountKey with Azure Storage Services

image005

  • Now you can get the access keys

image006

HOW NODE.JS WILL ACCESS THE APP SETTINGS

  • You will create a Node.js application inside of Azure Mobile Services

    • See previous steps

THE NODE.JS APPLICATION READING APP SETTINGS

  • You will starting by going back to Azure Mobile Services and drill down into your newly minted service
    • We called ours raspberrymobileservice

image007

  • Once you click API, you should see:

    image008

  • Notice the app settings are being read on lines 12 to 14.

raspberry pi Mono (software) mobile app Web Service azure Database API Container Common Language Runtime

Published at DZone with permission of Bruno Terkaly, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Integration Patterns in Microservices World
  • 6 of the Best API Testing Tools in the Market
  • Build Chatbots with Dialogflow - Step By Step Guidelines
  • Keep Your Application Secrets Secret

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: