Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.
/ BER Public archive

The code for the BER Service I demoed at Xamarin Summit

Notifications You must be signed in to change notification settings

DarqueWarrior/BER

Repository files navigation

BER Service

The BER Service was demoed during Donovan Brown's talk at the Xamarin Developer Summit 2019 in Houston TX.

The purpose of the service to update the back end URL of a mobile application without having to rebuild the mobile application. The BER Service is hosted at a URL that never changes and can be queried at runtime to get the URL of the back end. While the back end moves from environment to environment the BER Service is updated with the new back end URL for the mobile application to start using. The mobile application simply queries the BER Service before making a call to the back end to get the correct URL.

Repo Contents

This repo contains following:

  • BER Service Azure App Service Application with Azure DevOps Pipeline
    • Azure App Service, WebApp, BER Service implementation
    • YAML based Azure DevOps CI/CD pipeline
  • BER Service Client Library
    • Shared between the Azure Function and Azure WebApp implementations.
  • BER Service Data Access Layer using Entity Framework
    • Shared between the Azure Function and Azure WebApp implementations.
  • BER Service Azure Function App with Azure DevOps Pipeline
    • Azure Function App, BER Service implementation
    • YAML based Azure DevOps CI/CD pipeline
  • BER Service Azure Resource Manager Templates
    • Infrastructure as Code for both WebApp and Azure Function
    • Azure Resource Manager Templates
  • BER Service Model Library
    • Library that can be added to Xamarin applications to access a BER Service.
    • It is published on NuGet as Trackyon.BER.Client
    • There should be no reason to publish your own.
  • BER Service PowerShell Module
    • Provided for educational purposes only.
    • The module is published as Trackyon.Ber in the PowerShell Gallery.
    • There should be no reason to publish your own.
  • BER Service Unit Tests

Prerequisites

  • A GitHub account, where you can fork this repository. If you do not have one, you can create one for free.

  • An Azure DevOps organization. If you do not have one, you can create one for free. (An Azure DevOps organization is different from your GitHub organization. Give them the same name if you want alignment between them.)

  • An Azure account. If you do not have one, you can create one for free.

Deploy the Service as Azure Function

  1. Fork this repository into your GitHub account.

  2. Sign in to your Azure DevOps organization and navigate to your project.

  3. Create an Azure Resource Manager service connection named AzureConnection.

  4. In your project, navigate to the Pipelines page. Then choose the action to create a new pipeline.

  5. Walk through the steps of the wizard by first selecting GitHub as the location of your source code.

  6. You might be redirected to GitHub to sign in. If so, enter your GitHub credentials.

  7. When the list of repositories appears, select your repository where you forked this repository.

  8. Azure Pipelines will analyze your repository and recommend templates. Select Existing Azure Pipelines YAML file.

  9. Under path select azure-pipelines-function.yml, then select Continue.

  10. Select Variables, then select New variable, and then name the variable administratorLoginPassword. Next enter a strong password and check the Keep this value secret check box, and then choose OK, then Save.

  11. Select Run. Once the pipeline is complete you will have a BER Service deployed into an Azure Function.

  12. From the function app get the URL and default key.

Using the Service

From Mobile Application

To use the service in your mobile application you will need to add a reference to the BerService.Client library. You can build your own copy or download a version of Trackyon.BER.Client from NuGet.

When calling the function you are going to use the function key to authenticate.

var ber = new Trackyon.BER.Client.BerFunctionClient(functionURL, functionKey, version, appName);
this.baseAddress = ber.Get("back-end");

From DevOps Pipeline

To use the service in your DevOps pipeline you can call the REST API directly or use the cross-platform PowerShell Module Trackyon.Ber.

Install-Module Trackyon.Ber -Scope CurrentUser -Force -Verbose

Add-BerRecord -functionKey $(functionKey) -berUrl $(functionUrl) -appName $(appName) `
	-dataType 'back-end' -version $version `
	-value 'http://$(webSiteName).azurewebsites.net' -verbose

Deploy the Service as App Service

  1. Fork this repository into your GitHub account.

  2. Sign in to your Azure DevOps organization and navigate to your project.

  3. Create an Azure Resource Manager service connection named AzureConnection.

  4. In your project, navigate to the Pipelines page. Then choose the action to create a new pipeline.

  5. Walk through the steps of the wizard by first selecting GitHub as the location of your source code.

  6. You might be redirected to GitHub to sign in. If so, enter your GitHub credentials.

  7. When the list of repositories appears, select your repository where you forked this repository.

  8. Azure Pipelines will analyze your repository and recommend templates. Select Existing Azure Pipelines YAML file.

  9. Under path select azure-pipelines-website.yml, then select Continue.

  10. Select Variables, then select New variable, and then name the variable administratorLoginPassword. Next enter a strong password and check the Keep this value secret check box, and then choose OK, then Save.

  11. Select Run. Once the pipeline is complete you will have a BER Service deployed into an Azure Function.

  12. From the App Service get the URL.

Using the Service

From Mobile Application

To use the service in your mobile application you will need to add a reference to the BerService.Client library. You can build your own copy or download a version of Trackyon.BER.Client from NuGet.

When calling the web application you are going to use clientId to request a JWT to authenticate. The clientId must match either the Web or Mobile properties of the TokenData object. Those values are read from the application configuration. You can update those values in the azure-pipelines-website.yml file.

var ber = new Trackyon.BER.Client.BerClient(appServiceURL, clientId, version, appName);
this.baseAddress = ber.Get("back-end");

From DevOps Pipeline

To use the service in your DevOps pipeline you can call the REST API directly or use the cross-platform PowerShell Module Trackyon.Ber.

Install-Module Trackyon.Ber -Scope CurrentUser -Force -Verbose

Add-BerRecord -clientId $(appName) -berUrl $(berUrl) -appName $(appName) `
	-dataType 'back-end' -version $version `
	-value 'http://$(webSiteName).azurewebsites.net' -verbose

About

The code for the BER Service I demoed at Xamarin Summit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published