Giter VIP home page Giter VIP logo

az204-documentvault's Introduction

AZ204-DocumentVault

Azure Document Vault with Expiry

Project created in purpose to learn some things needed to pass AZ-204 exam.

App

I created the ASP.NET Core Web application (Razor Pages). This very very simple files storage like OneDrive.

Features:

  • Authorization: only logged in user can use it. Only users from my domain: tomaszprasolekgmail.onmicrosoft.com can log in.
  • Add files with name and tags.
  • See the list of all your files.
  • Download the files.
  • Delete the files.
  • Generate download link to the files. User must select an expiration time for it: 1/2/4 or 8 hours.
    • That link can be send to someone else to download it. That other person does not must to have the account in this app.

Note: The UI is very simple and minimalistic :-) I want to point out that I am not the frontend developer, I had little experience with HTML and CSS more then 10 years ago.

Upload page

Technologies used

  • ASP.NET Core Web application (Razor Pages). - web application
  • Azure App Service - hosting for web application
  • Azure Storage - stores the uploaded files
  • Azure Key Vault - stores the secrets
  • Cosmos Db - stores files data and metadata
  • App registraion - to be able to log in using Azure credentials (OpenId Connect)
  • Azure Function (HTTP trigger) to generate download link for blob
  • GitHub Actions to do deploy web application and Azure Function to the Azure
  • Bicep scripts - creates all infrastracture in Azure

Resource diagram

How to set up the CI/CD on Github and environment on Azure

Web App

  • Create resource group when all other Azure resource will be placed
  • Get your principal identifier from Azure, it is needed for the next script. You can find it: Users >> your user >> Object Id.
  • Run Azure Bicep script: main.bicep (AZ204-DocumentVault/Bicep/main.bicep) and pass Object Id as parameter
    • Command to run script: az deployment group create --resource-group rg-DocumentVault-ne --template-file .\AZ204-DocumentVault\Bicep\main.bicep --parameter parPrincipalId='azure-user-object-id'. Remember changing the resource group name and principal id.
    • The User Object Id is needed for... TODO: add what for is ObjectId needed
  • After create the resource in Azure, download publish profile from Azure:
    • Portal Azure >> Resource group >> App service >> Download publish profile
  • Put it in repository secret on Github. Secret name: AZURE_WEBAPP_PUBLISH_PROFILE. It is needed to Github Actions, to deploy app to WebApp in Azure.
    • Github repository >> Settings >> Secrets and variables >> Actions >> AZURE_WEBAPP_PUBLISH_PROFILE
  • Register the app in Azure:
    • Open App registrations view in Azure and register new app
      • App registrations >> New registration
      • Enter app name
      • Select Accounts in this organizational directory only (Default Directory only - Single tenant)
      • Redirect URI >> Web >> Link: https://webapp-documentvault-ne.azurewebsites.net/signin-oidc
        • If you want to the app locally you must also add https://localhost:7289/signin-oidc URL.
      • Set ID tokens (used for implicit and hybrid flows)
        • App registrations >> AZ204-DocumentVault >> Authentication >> Section: Implicit grant and hybrid flows
    • Add Directory (tenant) ID and Application (client) ID to Github project secrets. You can find it on Overview page of AZ204-DocumentVault registration page
      • Github repository >> Settings >> Secrets and variables >> Actions:
        • CLIENTID secret
        • TENANTID secret
    • Deploy app to Azure using Github Actions
      • Github repository >> Actions >> Workflows: Deploy to Azure Web App >> Run workflow

Azure Function

  • [???] CLI - create RBAC credentials [???]
  • After deploy the Azure Function, need to copy function URL to Github project secrets:
    • Resource group: rg-DocumentVault-FunctionApp-ne
    • Function app: functionApp-app
    • Overview tab >> Functions >> click function GenerateDownloadLink
    • Click Get Function URL on Overview tab
    • Copy function code and paste in in Github project secrets in variable GENERATEDOWNLOADMETHODFUNCTIONKEY

Commands

Deploy Bicep script when create resource group in it:

az deployment sub create --location northeurope --template-file .\AZ204-DocumentVault\Bicep\main.bicep

Create all needed resources:

az deployment group create --resource-group rg-DocumentVault-ne --template-file .\AZ204-DocumentVault\Bicep\main.bicep --parameter parPrincipalId='azure-user-object-id'

Links

Azure Cosmos Db

Azure Functions

Github Actions

Others

TODO

  • Make pipeline to run Bicep script and create infrastructure in the Azure
  • Add Azure Function, timger trigger - remove expired links from Azure CosmosDb
  • Add CDN integration

az204-documentvault's People

Contributors

tomaszprasolek avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.