Web Api Questions

by Admin 17. May 2017 10:47

What is Web API?

WebAPI is a framework which helps you to build/develop HTTP services.

Why is Web API required? Is it possible to use RESTful services using WCF?

Yes, we can still develop RESTful services with WCF. However, there are two main reasons that prompt users to use Web API instead of RESTful services.

  • Web API increases TDD (Test Data Driven) approach in the development of RESTful services.
  • If we want to develop RESTful services in WCF, you surely need a lot of config settings, URI templates, contracts & endpoints for developing RESTful services using web API.

Advantages of Web API are:

  • OData
  • Filters
  • Content Negotiation
  • Self-Hosting
  • Routing
  • Model Bindings

The latest features of ASP.NET Web API framework v2.0 are as follows:

  • Attribute Routing
  • Cross-Origin Resource Sharing
  • External Authentication
  • Open Web Interface NET
  • HttpActionResult
  • Web API OData

How can you handle errors in Web API?

Several classes are available in Web API to handle errors. They are HttpError, Exception Filters, HttpResponseException, and Registering Exception Filters.

What are main return types supported in Web API?

A Web API controller action can return following values:

  • Void – It will return empty content
  • HttpResponseMessage - It will convert the response to an HTTP message.
  • IHttpActionResult - internally calls ExecuteAsync to create an HttpResponseMessage
  • Other types - You can write the serialized return value into the response body

What is REST?

REST is architectural style. It has defined guidelines for creating services which are scalable. REST used with HTTP protocol using its verbs GET, PUT, POST and DELETE.

Tell me the code snippet to show how we can return 404 errors from HttpError?

Code for returning 404 error from HttpError

string message = string.Format(“TestCustomer id = {0} not found”, customerid);

return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);


How to handle errors in Web API?

Several classes are available in Web API to handle errors. They are HttpError, HttpResponseException, Exception Filters, Registering Exception Filters.


WebAPI is used for developing HTTP services

Who can consume WebAPI?

WebAPI can be consumed by any client which supports HTTP verbs such as GET, PUT, DELETE, POST. As WebAPI services don’t need any configuration, they are very easy to consume by any client. Infact, even portable devices like Mobile devices can easily consume WebAPI which is certainly the biggest advantages of this technology.


Web Api Versioning

Query String



Azure Questions

What is Cloud Computing?

Cloud computing is a term referred to storing and accessing data over the internet. It doesn't store any data on the hard disk of your personal computer. In cloud computing, you are allowed accessing data from a remote server.

It is the use of servers on the internet to “store”, “manage” and “process” data.

What is Microsoft Azure?

Azure is a cloud computing platform which was launched by Microsoft in Feb 2010. It is a highly flexible cloud platform that offers development, data storage, service hosting, and service management.

Roles are a very important concept in Windows Azure, and learning them is the base for further programming.

Three types of roles in Windows Azure are:

  • Web Role: It is used to deploy website by using language which is supported by the IIS platform customized to run the web apps.
  • Worker Role: It helps you to execute the process that runs in the background.
  • VM Role: It helps you to schedule the windows services and tasks. (a combination of Web Role & Worker Role.)

Why should you use Azure CDN? Azure CDN should be used to reduce load time and bandwidth as well as speed the responsiveness.

Name some important applications of Microsoft Azure

Most important application of Microsoft Azure are:

Infrastructure Services, Mobile Apps, Web Applications, Cloud Services, Storage, Media Services, etc.

What is Azure as PaaS? PaaS is a computing platform that includes an operating system, programming language execution environment, database, or web services. Developers and application providers use this type of Azure services.

Explain Cmdlet command of Microsoft Azure A cmdlet is a command which is utilized as a part of the Microsoft PowerShell environment. The cmdlet is called by the Windows PowerShell to automate the scripts which are in the command line.

What is the use of Azure Active Directory?

Azure Active Directory is an identity and access management system (IAM). It is very much similar to the active directories. It allows you to grant your employee in accessing specific products and services within the network.

What is HDInsight in Microsoft Azure?

HDInsight is a cloud service which that makes it easy. It is fast and cost-effective to process a massive amount of data using with the help of open-source frameworks like Spark, Hadoop, Hive, Storm and R. HDInsight offers various type of scenarios which includes ETL, data warehousing, and Machine Learning

Explain the term 'service fabric' in Azure

Service fabric is a middleware platform which gives more scalable outcome. It mostly renders with a more managed and reliable enterprise.

Azure Service Fabric is a distributed systems platform that makes it easy to package, deploy, and manage scalable and reliable microservices and containers. Service Fabric also addresses the significant challenges in developing and managing cloud native applications. Developers and administrators can avoid complex infrastructure problems and focus on implementing mission-critical, demanding workloads that are scalable, reliable, and manageable. Service Fabric represents the next-generation platform for building and managing these enterprise-class, tier-1, cloud-scale applications running in containers. https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-overview

Name the types of web application which can be deployed with Azure

ASP.Net, PHP, WCF are a type of web application which can be deployed with SQL Azure.

Explain the service definition file The course service definition file (.csdef) defines the service mode. It includes a number of roles.

Name the services which are used to manage resources in Azure

  • Application Insights
  • Azure Portal
  • Azure Resource manager
  • Log Analytics

What are the important drawbacks of using Microsoft Azure?

  • Cloud computing is not possible if you are not able to connect to the Internet.
  • Azure is a web-based app which needs a lot of bandwidth to download, as do large documents.
  • Web-based applications can sometimes be slower compared accessing similar software program on your desktop PC.

What is MOSS? Microsoft SharePoint Server (MOSS) that consist of a complete version of the portal platform. It allows a user to manage, share and even create the document.

What is the use of VNET?

VNet is a representation of your own network in the cloud. It logically isolates your instances launched in the cloud, from the rest of your resources.

What are stateful and stateless microservices for Service Fabric?

Explanation: Service Fabric enables you to build applications that consist of microservices. Stateless microservices (such as protocol gateways and web proxies) do not maintain a mutable state outside a request and its response from the service. Azure Cloud Services worker roles are an example of a stateless service. Stateful microservices (such as user accounts, databases, devices, shopping carts, and queues) maintain a mutable, authoritative state beyond the request and its response. Today’s Internet-scale applications consist of a combination of stateless and stateful microservices.


What is Azure Functions?

Azure Functions is an event driven, compute-on-demand experience that extends the existing Azure application platform with capabilities to implement code triggered by events occurring in virtually any Azure or 3rd party service as well as on-premises systems.

Azure Functions is a tool in the Serverless / Task Processing category of a tech stack.

Auto Scaling: There two type / workflow of Scaling:

·       Scale Up (Vertical Scaling)

Make it bigger. Its means Get More size of CPU, Memory, Disk space etc. You scale up by changing the pricing tier of the App Service plan that your app belongs to.  Ex: Increase the RAM size from 2 TB to 10 TB.

·       Scale out (Horizontal Scaling)

Add more Instances. It’s like upgrading the capacity of the app / server by creating/ adding more instances of same size. Using Load balancer, you can manage all request coming from end users. Suppose your Sever has 10 GB RAM, 200 TB HDD space, 10 core etc. so while scaling out this server you will create more instances of servers with same configuration.

Horizontal scaling Vs.  Vertical Scaling

Here are few points which are important when we think about going with Horizontal scaling or Vertical Scaling.

·       Scaling up require down time, in this case you need to upgrade server’s configuration like RAM, memory, CPU etc. so while upgrading this configuration your server require downtime. Once you are done with update, restart of server is required.

·       Scaling up will Increase performance but not availability, because its only one instance if it can go down anytime.

·       Scale Out not require down time, in Scale out its crates new instances of server it don’t touch to existing instance so no downtime require.  

·       Scale Out, Increase performance and availability as well. When you increase no of instances and handle load / request using load balancer it’s increase performance of server but also increase availability as well.

Azure Service Busis a fully managed multi-tenant cloud messaging service (MAAS). It is brokered messaging system. Applications and services can communicate with each other using messages via Service Bus. Message consists of two parts; message properties and message payload. Message properties is a dictionary of values against property keys. Message payload is in binary format, which can contain JSON, XML, or text data.


Azure Service Bus offers three types of communication mechanisms; queues, topics and, relays. Queues and Topics, facilitate one-directional communication. Messages will be stored until they are consumed. Each message in Queue is received by a single recipient. Topic can have multiple subscriptions for multiple receivers. Subscriptions can choose to receive messages based on parameters. Messages from Queues and Topics can be accessed using Service bus-defined messaging APIs or REST APIs. SDKs are also available for other languages. Unlike Queues and Topics; Relays provide bi-directional communication and does not store messages.

To use these messaging services, user must create namespace under Azure subscription. A namespace can be visualized as a logical container for messaging components. Multiple Service Bus components (queues, topics and relays) can reside within a single namespace.



Why Service Bus

As Azure Service Bus is fully managed service, scaling and availability will be taken care by Azure team. It is integrated with other Azure services like, Event Grid, Logic Apps, Stream Analytics etc. Azure Service Bus provides reliable and secure asynchronous message communication platform along with facility of delayed processing of events or data. Shared Access Signatures (SAS), Role Based Access Control (RBAC) and Managed Service Identity (MSI) protocols are supported by it. Service Bus also supports client libraries for .NET, Java, JMS.


Comments are closed


Tag cloud