Skip to content

Hafzan-250601/SmartHotel360-Website

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project is retired, archived, and no longer supported. You are welcome to continue to use and fork the repository.

For the latest sample references visit: https://aka.ms/tailwindtraders & https://aka.ms/rpsls

SmartHotel360

We are happy to announce the release of SmartHotel360. This release intends to share a simplified version of SmartHotel360 reference sample apps used at Connect(); 2017 Keynotes. If you missed it, you can watch Scott Guthrie’s Keynote: Journey to the Intelligent Cloud in Channel 9.

We updated the code for this repository to support Scott Hanselman's General Session from Ignite 2018, An end-to-end tour of the Microsoft developer platform.

SmartHotel360 Repos

For this reference app scenario, we built several consumer and line-of-business apps and an Azure backend. You can find all SmartHotel360 repos in the following locations:

SmartHotel360 - Website

Welcome to the repository containing the website of SmartHotel360. SmartHotel360 has multiple apps that share a common backend, including a public website where hotel guests can book a room, smart conference rooms, and even verify if their pets are allowed in the hotel.

SmartHotel360 Home Page SmartHotel360 Home Page

Getting Started

Once downloaded you can open the SmartHotel360.WebSite.sln file, located in the Source folder to open the solution in Visual Studio 2017 15.5 or higher. This solution contains two projects:

  • The SmartHotel360.Website project: An ASP.NET Core website which is a web app developed using React+Redux and server-side rendering.

  • The SmartHotel360.WebsiteFunction project: An Azure Function used to analyze photos of pets using the Cognitive Services Vision API and Azure Cosmos DB.

Note: You will need NodeJS installed and Azure CLI in order to run the solution locally.

Deploy to Azure

We will need an Azure Function (for the pet checker feature), Blob Storage (for storing the pets images), Cosmos DB (stores documents with the pet information), Vision API (to recognize the pets), SignalR Service (to manage the requests), App Service (for the website) and Application Insights (for monitoring).

We have added an Azure Resource Manager Template so you can automate the creation of these resources:

Deploy to Azure

Note: Some Azure resources are needed even if you want to run the Function locally.

Once the resources are created you will need to follow a couple of manual steps:

  1. Create a blob storage container called pets in the storage account and ensure it has public access.

Public Blob Storage

  1. Create a database in the CosmosDB called pets. Then add one collections called checks.

Cosmos DB Collection

Running the Solution Locally

Set SmartHotel360.Website as startup project, then hit F5 to start debugging. The web is configured to use the public endpoints for the backend, so you don't need to run the backend locally.

Configuring the Website

The file appsettings.Development.json contains the settings of the website. By default, the following options are used:

  • SettingsUrl: URL of the configuration endpoint. By default, it uses the public endpoint service. Change this value if you have deployed the Backend Services and want to use your own backend.
  • FakeAuth: Contains data to "simulate" the login process. Data is Name (name of the user), UserId (id of the user), PicUrl (URL of the user avatar).

If FakeAuth is not set the Website will use an Azure Active Directory B2C to enable the logins.

If you want to run or deploy the Azure Function to enable the Pet Checker feature open the file appsettings.Development.json or appsettings.Production.json according to your Build configuration, Production if you are using a Release configuration or Development if you are using a Debug configuration. Then edit the PetsConfig section with the following entries:

Configuring the Azure Function

Open the project SmartHotel360.WebsiteFunction and edit the local.settings.json file with following entries:

  • AzureWebJobsStorage: Storage Account Connection String
  • AzureWebJobsDashboard: Storage Account Connection String
  • cosmos_uri: Cosmos DB (SQL API) URL (eg. https://petpictureuploadmetadata.documents.azure.com:443)
  • cosmos_key: Cosmos DB (SQL API) Key
  • constr: Cosmos DB (SQL API) Connection String
  • MicrosoftVisionApiKey: Cognitive Services Vision API Key>
  • MicrosoftVisionApiEndpoint:Cognitive Services Vision API URL (eg. https://southcentralus.api.cognitive.microsoft.com/vision/v1.0)
  • MicrosoftVisionNumTags: Tags to fetch from Vision API. For example: 10
  • AzureSignalRConnectionString: Connection String to the SignalR Service instance

Running the Website and Function locally

In order to run the Website and the Function locally you will need to setup the solution with multiple startup projects:

  1. Right click on the solution and then click on properties.
  2. Select the option Multiple startup projects.
  3. Select option Start in the Action column.

Now, you should be able to run both the Website and the Azure Function locally and debug it. If the Azure Function is not triggered be sure that:

  1. The blob container has public access.
  2. The local.settings.json file contains the correct cosmos_uri, cosmos_key and constr values.
  3. The website uses the correct configuration settings from SettingsUrl. It should save the pet images in a blob container called pets in your storage. It should also create documents in a collection called checks in a database pets. You can verify this using the Data Explorer. Be sure that the both database and collection exists on Cosmos DB:

Pets document in Cosmos DB

Deploying to Azure

Once the resources and settings are created and configured, you can publish the website to App Service and the Function to Function App Service.

Deploying the Website to Azure

To deploy the website in Azure you can use the Publish button from Visual Studio to deploy to the Azure App Service.

If you deploy the website to an App Service and you disabled the FakeAuth to use Azure B2C be sure to go back to FakeAuth because you won't be able to use Azure B2C to login (the redirect URL of your own app service won't be in B2C).

Note: in productions scenarios we recommend you use Azure Pipelines for build and releases process.

Deploying the Function to Azure

You can use the Visual Studio 2017 Publish feature to publish the Azure Func