Skip to content

Latest commit

 

History

History
112 lines (95 loc) · 5.73 KB

4.1. Creating Web Applications using PaaS.md

File metadata and controls

112 lines (95 loc) · 5.73 KB

Creating Web Applications using PaaS

App Service Environments (ASEs)

  • Isolated/dedicated environment for securely running App Service apps.
  • High scale: Multiple ASEs can be used to scale horizontally
  • Isolation and secure network access
    • Isolated running only one customers applications.
    • Always deployed into a VNet.
      • Can have network security groups (NSGs) to control inbound & outbound traffic.
      • Can have web application firewalls (WAFs)
  • It's deployed on App Service Plan.
  • Can run Web Apps, Docker containers, Mobile Apps, Functions
  • Pricing: comes with its own pricing tier "Isolated offering"
  • ❗ Limitations
    • Everything in-between from
      • Single instance in 100 app service plans
      • 100 instances in a single App Service plan
  • Consists of two parts
    1. Front-ends: Responsible for HTTP/HTTPS termination, automatic load balancing.
    2. Workers: Host customer apps. Three fixed size:
      • One VPU/3.5 GB RAM,Two vCPU/7GB RAM, Four vCPU/14 GB RAM

Web App

  • VNET Integration exists only in Standard, Premium, Isolated.
  • Create an Azure Service Web App
    • Create resource group => Create app service plan => Create web app => Deploy the app

Web App for Containers

  • Choose Docker image
    • or with deployment configuration file for Docker Compose / Kubernetes image from Azure Container Registry, Docker Hub, Private Registry.
  • Web App for Containers vs Azure Container Instances
    • Web Apps for Containers
      • Deploy web applications on Linux using containers
    • Azure Container Instances
      • Easy way to run containers on Azure with a single command without any orchestration.

WebJobs

  • Background tasks that enables you to run a program or script in the same context as a web app.

    • E.g. .cmd, .bat, .exe, .ps1, .sh, .php, .py, .js, .jar
  • To create you can have CI/CD from GitHub or upload .zip containing your WebJob directly.

  • Set "Always On" for reliability.

  • 📝 Scheduled vs continuous

    Context Scheduled Continuous
    Start When scheduled or triggered manually. Immediately. Runs in an endless loop.
    Multiple instances of WebJobs On a single instance that's load balanced. Runs all on instances
    Remote debugging Not supported Supported
    Scaling Not supported Determines whether the program or script runs on all instances or just one instance. ❗ Not possible on Free or Shared pricing tiers.

Using Swagger to document an API

  • Swagger is set of tools around OpenAPI (JSON standard to define APIs)
  • Swashbuckle
    • .NET Core package that builds swagger documents from code.

    • Embeds UI for customizing swagger documents.

    • Set up:

      • In Startup.ConfigureServices: services.AddSwaggerGen(c => c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" }));
      • You can here document other information such as Contact, License, TermsOfService, and Description.
    • Enable middleware & set-up json UI in Startup.Configure:

        app.UseSwagger();
        app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
      • Swagger is then accessible at /swagger/v1/swagger.json and /swagger
    • Build swagger from XML documentation:

      • Enable XML documentation file in .csproj: <GenerateDocumentationFile>true</GenerateDocumentationFile>

      • You'll get warning for undocumented types and members.

        • You can suppress them with inline code or set <NoWarn>$(NoWarn);1591</NoWarn> in .csproj.
      • In Startup.ConfigureServices enable XML documents via reflection:

          c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"));
      • You can then just XML document Action results with <summary> and <param name ="id"> tags.

  • Declaring models with attributes
    • You can set attributes on view models such as [Required] or [DefaultValue(false)]
    • On controller you can use [Produces("application/json")]
    • On actions you can use [ProducesResponseType(201)] and then document with <response code="201"/> XML tag.

Azure Logic App

  • IPaaS: Integration Platform as a Service
  • Automate tasks & integrates apps, data, systems and services by automating tasks and business processes as workflows.
  • Workloads e.g.:
    • Move uploaded file from an SFTP or FTP server to Azure Storage.
    • Process and route orders across on-premises systems and cloud services.
    • Monitor tweets for a specific subject, analyze the sentiment, and create alerts or tasks for items that need review.
  • 200+ integrations such as Service Bus, Functions, Microsoft 365, Oracle DB etc.
    • Each connector provides triggers and/or actions specifically.
    • Enterprise Integration Pack
      • Handles B2B integrations, like BizTalk.
      • Can handle different protocols such as As2, X12, EDIFACT
      • Can transform different formats.
      • Support for encryption & digital signatures.
      • Flow
        • Create an integration account in the portal => Add partners, schemas, artifacts, maps & agreements (reusable artifacts) => Create logic map => Link Logic app to the account => In Logic App, you can use partners and other artifacts from the integration account.
  • You can have custom connectors.
    • They're function-based (Azure Functions).
    • Flow: Build your API => Describe your API (Swagger/OpenAPI) and define connector => Use connector => (Optional) Share & Verify your connector
  • Applications are defined in a JSON file, they support ARM.
  • You can use Azure portal or Visual Studio.
    • Visual Studio
      • You can add apps to source control, publish different versions.
      • Flow: New > Project => Visual C# => Select Resource Group => Modify LogicApp.json => Deploy