page_type | languages | products | description | name | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
|
|
This is a Xamarin app that gives users the opportunity login and create reviews for businesses and or restaurants. |
The Business Reviewer (Xamarin) |
This is a Xamarin app that gives users the opportunity login and create reviews for businesses and or restaurants. In addition to being able to leave a text review, the user can also upload photos and videos.
The app showcases how to use several Azure offerings in the context of a mobile application - including how to create accounts and stream videos.
This project demonstrates the following:
- Xamarin.Forms
- MVVM architecture
- Azure AD B2C
- Azure App Services
- Azure Cosmos DB
- Azure Functions
- Azure Storage
- Azure Media Services
To get started clone this repository and then follow the directions in the Quick Start section below to setup the Azure infrastructure. Once done, you will be able to run the app.
- Visual Studio or Visual Studio for Mac.
- Azure subscription (create a free one here.)
- Clone this repository.
- Open the
/src/Reviewer.sln
in either Visual Studio or Visual Studio for Mac. - Restore all NuGet packages.
In order to run this full sample, an Azure subscription is required. You can create a free subscription here.
Note: When creating the Azure offerings below - use the same Resource Group. And when given the option to pick a Storage Account - pick the same one for each.
Once you have a subscription, you will need to create several Azure offerings:
Setting up Azure AD B2C is the most involved portion.
- First you need to create the tenant.
- Next you need to create your application.
- Within the application, create a scope, and name it
rvw_all
.
- Within the application, create a scope, and name it
- Next you need to add any identity providers.
- Then you need to create a sign-up/sign-in policy.
- Create an Azure Cosmos DB - SQL API - instance.
- Create a database named:
BuildReviewer
- Create a database named:
- Create a collection named:
Businesses
- Create a collection named:
Reviews
-
Create the Azure App Service.
-
Configure the
Reviewer.WebAPI
project'sappsettings.json
file to match the following:"AzureAdB2C": { "Instance": "https://login.microsoftonline.com/tfp/", "ClientId": "", "Domain": "", "SignUpSignInPolicyId": "", "AllAccessScope": "rvw_all" }
- The
ClientId
value will be the Application ID of your Azure AD B2C application. - The
Domain
will be the Domain Name of your Azure AD B2C tenant. - The
SignUpSignInPolicyId
will be the name of the sign-up/sign-in policy you created.
- The
-
Update the following variable values in
Reviewer.Services.APIKeys
:CosmosEndpointUrl
: Obtained from the API Keys blade of the portal for Cosmos DB.CosmosAuthKey
: The primary key from the API Keys blade of the portal for Cosmos DB.WebAPIUrl
: The URL of this Azure app service, can be obtained from the overview blade in the portal. (Make sure to include the trailing backslash.)
-
Deploy the
Reviewer.WebAPI
ASP.NET Core Web API application to the Azure App Service instance.
- Create an Azure Media Services instance.
- Use the same Azure Storage account as created above.
- Start the default streaming endpoint.
- Create an Azure AD application for it.
- Create an Azure AD service principal.
- Create an Azure Function App.
- Use the same Azure Storage account as created above.
- Create the following Application Settings keys with values:
AMSAADTenantDomain
: The Azure AD domain you created for the AMS app in step 4 in the Azure Media Services setup above.AMSClientId
: The Azure AD client ID for the Azure Media Services application you created during the Azure Media Services setup above.AMSClientSecret
: The secret key obtained during the Azure Media Services AD creation steps above.AMSRESTAPIEndpoint
: Obtained on the Azure Media Services overview blade in the portal.MediaServicesStorageAccountKey
: Obtained on the Primary Storage ID of the AMS Properties blade.MediaServicesStorageAccountName
: Obtained on the Primary Storage Name of the AMS Properties blade.Reviews_Cosmos
: The Azure Cosmos DB connection string (obtained on the keys blade for Cosmos DB).WebhookEndpoint
: This will need to be obtained after you deploy the Function app. It is the URL of the AMSWebhook function.
Note that all of those settings can also be put into your local.settings.json to debug locally.
Finally there are a couple of settings that you need to configure in the Xamarin.Forms project to ensure it can communicate to the Azure offerings.
- In the
Reviewer.Services.APIKeys
class fill in the values for the following variables:SASRetrievalUrl
: The function URL of the SASRetrievalURL function.WriteToQueueUrl
: The function URL of the WritePhotoInfoToQueue function.StorageAccountName
: Within the Azure Storage service - the Storage Account Name as found on Access Keys blade.PhotosContainerName
: review-photos
There are a couple things to note when running the demo.
- The Xamarin.Forms app needs to run with an Android version that supports custom tabs.