10 Deployment Cloud Services And Containerization

NET Centric Computing · Unit 10

Deployment, Cloud Services and Containerization

Exam-focused notes for Deployment, Cloud Services and Containerization (NET Centric Computing, BIT351): what the TU syllabus asks and how it has actually been tested, with 4 solved past questions from this unit.

Deployment, Cloud Services and Containerization in short

After a web app is built, it must be placed on a server where users can reach it. This chapter covers deployment steps, publishing to Azure, hosting models and Docker containers.

Deployment, Cloud Services and Containerization: notes

ASP.NET Core deployment procedures

Deployment means moving the finished application to a server and making it run. For ASP.NET Core, the usual procedure is:

  1. Finish and test the app in a Development environment.
  2. Set production settings: connection strings, logging level and secrets in environment variables or a secret store, not in code.
  3. Publish a Release build.
  4. Copy the published files to the server.
  5. Install the .NET runtime (or ASP.NET Core Hosting Bundle for IIS) on the server.
  6. Configure the web server or host, such as IIS, Nginx or a container.
  7. Set up HTTPS with a certificate and the correct ports.
  8. Start the app, then test it and watch the logs.

Publish command:

dotnet publish -c Release -o ./publish

This compiles in Release mode and puts the app and its dependencies in the publish folder. Two publish styles exist:

  • Framework dependent: smaller, needs the .NET runtime on the server.
  • Self contained: includes the runtime, so it runs even when .NET is not installed.

To run it on a Linux server behind Nginx:

dotnet MyApp.dll --urls "http://localhost:5000"
server {
    listen 80;
    server_name example.com;
    location / {
        proxy_pass         http://localhost:5000;
        proxy_set_header   Host $host;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
}

A process manager such as systemd keeps the app running and restarts it after a crash.

What this unit covers

  • ASP.NET Core deployment procedures
  • Azure cloud publishing
  • Hosting models for ASP.NET Core
  • Docker uses and benefits

Hosting models for ASP.NET Core

2081 · 5 marks

Describe any two hosting models for ASP.NET core application. [5]

Note: The reference notes did not contain material on this topic. The following answer is based on standard ASP.NET Core documentation and is correct for TU BSc CSIT examinations. --- In the in-process hosting model, the ASP.NET Core application runs inside the IIS worker process (w3wp.exe for II...

Open this answer on its own page →

Azure cloud publishing

2080 · 10 marks

How do you publish application to Azure cloud? Illustrate the concept of SQL injection attack with example and its prevention procedure.[10]

--- Note: Reference notes were not available for this topic. The following is based on standard Microsoft Azure deployment practices as taught in BSc CSIT curriculum. Publishing an application to Azure means deploying your web application (e.g., ASP.NET, Node.js) to Microsoft's cloud platform so ...

Open this answer on its own page →

Docker uses and benefits

2081.1 · 5 marks

List the uses of docker. How do you secure controller and action methods? [5]

Show solved answer

Uses of Docker and Securing Controller/Action Methods


Uses of Docker [2.5 marks]

Docker is a containerization platform that packages applications and their dependencies into lightweight, portable containers. Its main uses include:

  1. Application Portability

    • Docker containers run consistently across different environments (development, testing, production), eliminating the "it works on my machine" problem.
  2. Microservices Architecture

    • Docker enables breaking down large applications into small, independent microservices, each running in its own container.
  3. Continuous Integration and Continuous Deployment (CI/CD)

    • Docker integrates with CI/CD pipelines (Jenkins, GitHub Actions) to automate building, testing, and deploying applications.
  4. Isolation and Resource Management

    • Each container runs in isolation with its own filesystem, network, and process space, preventing conflicts between applications.
  5. Rapid Deployment and Scaling

    • Containers start in seconds and can be scaled up or down quickly using orchestration tools like Kubernetes or Docker Swarm.
  6. Version Control for Environments

    • Docker images can be versioned, allowing rollback to previous application states easily.
  7. Simplified Dependency Management

    • All dependencies are bundled inside the container image, removing the need to install them separately on the host machine.

Securing Controller and Action Methods in ASP.NET MVC [2.5 marks]

In ASP.NET MVC, controllers and action methods can be secured primarily using the [Authorize] attribute.

1. Using [Authorize] Attribute

The [Authorize] attribute restricts access to authenticated users only.

On a Controller (secures all actions):

[Authorize]
public class AdminController : Controller
{
    public ActionResult Dashboard()
    {
        return View();
    }
}

On a specific Action Method:

public class HomeController : Controller
{
    [Authorize]
    public ActionResult SecretPage()
    {
        return View();
    }

    public ActionResult PublicPage()
    {
        return View();
    }
}

2. Role-Based Authorization

Restrict access to users belonging to specific roles:

[Authorize(Roles = "Admin, Manager")]
public ActionResult ManageUsers()
{
    return View();
}

3. Using [AllowAnonymous] Attribute

Allows specific actions to be publicly accessible even when the controller is secured:

[Authorize]
public class AccountController : Controller
{
    [AllowAnonymous]
    public ActionResult Login()
    {
        return View();
    }

    public ActionResult Profile()
    {
        return View();
    }
}

4. Global Authorization Filter

Apply authorization globally to all controllers in FilterConfig.cs:

public class FilterConfig
{
    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new AuthorizeAttribute());
    }
}

Summary Table

MethodScope
[Authorize] on ControllerAll actions in the controller
[Authorize] on ActionOnly that specific action
[Authorize(Roles="Admin")]Only users in specified role
[AllowAnonymous]Bypasses authorization
Global FilterEntire application
Open this answer on its own page →

ASP.NET Core deployment procedures

0 · 5 marks

How do you deploy ASP.NET core applications? List the procedures. [5]

Note: The reference notes did not contain material on this topic. The following answer is based on standard ASP.NET Core deployment knowledge, which is consistent with the TU BSc CSIT curriculum. --- Deployment is the process of publishing and hosting an ASP.NET Core application so that it can be...

Open this answer on its own page →