This post intends to cover the answers to the questions which a Azure developer can face at an Interview i.e. Azure Developer Interview Questions and Answers on Azure Service Bus
For logic app related read following - Developer Interview questions on Logic App
1. What are the services offered under Service Bus ?
- There are three services offered under Service Bus
i. Service Bus Queue
ii. Service Bus Topic
iii. Service Bus Relay
Queues and Topics, store messages until they are consumed and support one-directional communication. Whereas Relays does not store messages and provide bi-directional communication.
2. Does service bus support push-push model?
- No.
It only supports push - pull model.
Where the publisher pushes messages in service bus queue/topic and the subscriber/consumer have to pull the message.
Service bus doesn't push messages to consumer/subscriber and it stores the message until it is consumed or it's TTL is met.
3. Can we use queue and topic interchangeably?
- Technically Topic can be used and can be implemented to behave as queue.
i.e. having a Topic with single subscriber/consumer.
However, the opposite(making queue behave like Topic) is difficult to implement.
4. In which scenario will you recommend Service Bus ?
- In a scenario, where we are looking for communication which is not synchronous and reliability is of most important, Azure service Bus is good candidate.
In an asynchronous scenario where the consumer system takes some time to process, having the messages stored is important.
In a scenario where there is requirement of Enterprise level features (see question 7).
Where there is need to decouple applications of any size hosted natively on Azure, on-premise, or from any other cloud vendor.
5. What is difference between Receive-and-delete and peek-lock mode?
- Both are modes in which consumers can receive messages from Service Bus.
Receive-and-delete process is often called at-most once processing(each message is processed at most once - chances of message loss in case of any failure ). Deletes the messages as soon as it is picked by consumer for processing.
Peek-lock process is often called at-least once processing(each message is processed at least once - less chances of message loss in case of any failure). When the message is picked, a lock is placed on it making it unavailable to other competing consumers and once processing is completed it will invoke Complete() function and message will be removed from queue. If consumer fails to process or does not respond within specified time interval(default 5 mins), Abandon() function will be invoked and message will be available for other consumers.
6. What are the protocols used to connect to Service Bus?
- The protocols which can be used to connect to service bus can be either of
i. SB-Messaging
ii. AMQP
iii. HTTP/REST
7. What are the features of Azure Service Bus?
- Below are some of the out of box features of Azure service Bus
- Scheduling
- Dead-lettering
- Transactional processing
- Message ordering
- Expiration (TTL)
- Duplicate detection
- Deferring
- Pub/Sub
- Filtering
8. What does Service Bus Message consists of?
- Service Bus Message consists of two parts
- Message properties
- Message payload.
Message properties is in a key value form i.e. dictionary of values against property keys. Whereas message payload is in binary format, which can contain XML, JSON or text data.
9. Does Azure Service bus support synchronous communication?
- With Relay option only, synchronous communication is supported.
10. Does Azure service bus store data?
- Yes and no.
If Azure service Bus queue and Azure service Bus Topic is used then yes it stores data, whereas if Azure Service Bus relay is used then no data is stored.
11. What is the message delivery/consumption mode used in Azure Service Bus Queue and Topic?
- Following delivery/consumption mode - pub/sub with a pull model, competing consumers and partitioning can be achieved with the use of topics, subscriptions and actions.
12. What is namespace in Azure service bus?
- It is a logical container of the components of Service Bus - Queues, Topics, Relays.
There is one to many relationship i.e. one namespace can have multiple queues, topics etc. created within it.
13. Can I migrate Azure Service Bus namespace from one subscription to another?
- Yes it is possible and it can be done using Azure portal and also with help of powershell commands provided below two conditions are satisfied
- The Azure service bus namespace must already be active.
- The user executing the commands must be an administrator on both the source and target subscriptions.
14. How can we secure access to Azure Service Bus?
- With the help of RBAC, Shared access signature and Managed Identity.
15. What are the types of messages supported by Azure Service Bus?
- Two types of messages are supported by Azure Service Bus
- Relayed message – part of synchronous communication – used with Service bus relay
- Brokered message – part of asynchronous communication – used with Service bus queue and topic