Publish and Consume Azure Service bus queues pro-grammatically in C#

You can easily publish messages in to the queue and subscribe messages from queue pro grammatically using C#
Publish messages in to queues

var connectionString = "Endpoint=sb://;SharedAccessKeyName=messagecollectionlistener;SharedAccessKey=DnentJvFthm13IWicMJxrM68LK3c+zEeQb6QlQn71SA=;EntityPath=messagecollection";
var client = QueueClient.CreateFromConnectionString(connectionString);
var lastKey = ' ';
var count = 1;
while (lastKey != 'q')
var body = $"Message {count++}";
var message = new BrokeredMessage(body);
Console.WriteLine($"Sent {message.MessageId}");
lastKey = Console.ReadKey().KeyChar;


var connectionString = "Endpoint=sb://;SharedAccessKeyName=messagecollectionlistener;SharedAccessKey=DnentJvFthm13IWicMJxrM68LK3c+zEeQb6QlQn71SA=;EntityPath=messagecollection";
var client = QueueClient.CreateFromConnectionString(connectionString);
client.OnMessage(message => {
Console.WriteLine($"Message : {message.MessageId} Message Body : {message.GetBody()}");

Connection string you can copy from here

Elastic Search – 403 – cluster_block_exception

I got an error while adding a new document to an existing index.

cluster_block_exception –¬† u’blocked by: [FORBIDDEN/12/index read-only / allow delete (api)]

Below are the put request I have tried to send

I resolved this error by sending a new put request to the products index( which are already created before) by updating the blocks.read_only_allow_delete to false.

Url you have to send the put request


In my case the index is products


Body parameter that you are passing along with the request


After the successful request I got the exact result I am expected



Windows 10 Start menu stopped working

My windows 10 start menu suddenly stopped working.Below are the steps I have done to make it working.

1. Open Windows Powershell Command as Administrator
2.Run the command Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml”}

Wait until the process completes(Ignore the red errors) and finally restart Windows.

Webpack throwing TypeError: Data must be a string or a buffer in Angular CLI

Recently I got some error unexpectedly while running my Angular-CLI application.

By default you will not get any information about the error which WebPack is throwing. But I will tell you , how you can log the exact error related to your issue. The reason could be different for your scenario.

Navigate to yoursource\node_modules\webpack\lib\dependencies and open HarmonyExportImportedSpecifierDependency.js file and log the import dependency
updateHash(hash) {
const hashValue = this.getHashValue(this.importDependency.module);
if (this.importDependency.module != null){
// console.log('Module resource: ', this.importDependency.module.resource);
console.log('\nFile not found: ', this.importDependency);

In my case I got the module in my application where the issue is.

Hope this helps

Template Variable to Interact with Child Components in Angular 2+

I have already discussed in my last couple of blogs to interact Components using @Input and @Output. Here I am going to explain about Template Variable to interact with Child Components. By using this Template reference variable you can access public properties and methods of a child component and also to bind data to a child component.
Template Reference Variable allow you to specify a variable name on a component and you can access any public property or methods on that component using that variable.

In order to demonstrate I have a product card component which is my child component placed inside the  ProductListComponent(parent component) to list some products. You can see I have added a template reference variable named #productReference on this child component

So over here in our ProductCardComponent will just a create a method and property to access from the ProductListComponent

Now you can access this property and method from the ProductListComponent

Load Components Dynamically at runtime in Angular 4

Angular Version I have used – 4.2.0
Here I am going to explain how to load dynamic components at runtime. By using angular ComponentFactoryResolver you can load components dynamically. In the below example I am loading a component dynamically in to another component at runtime .

In order to load a dynamic component you have to create a directive that you can apply to ng-template , which will helps to place the components at run time. This directive injects ViewContainerRef to gain access to the view container of the element that will host the dynamically added component.
import { Directive, ViewContainerRef } from '@angular/core';
selector: '[dynamiccomponent-host]',
export class DynamicComponentHostDirective {
constructor(public viewContainerRef: ViewContainerRef) {


This is just a place holder component to load the dynamic component.This component accepts an input(contains what component you want to load at runtime)  which is coming from a parent components or you can load from your service based on your implementation. This component is doing the major role to resolve the components at runtime. In this method you can also see a method named renderComponent() which ultimately loads the component name from a service and resolve with ComponentFactoryResolver and finally setting data to pass the dynamic component.
import { Component, Input, OnInit, AfterViewInit, ViewChild, ComponentFactoryResolver, OnDestroy } from '@angular/core';
import { DynamicComponentHostDirective } from './DynamicComponentHost.Directive;
import { YourInputDataModel } from './Data.Model';
import { DynamicComponentService } from "./DynamicComponent.Service";
selector: 'container-component,
templateUrl: 'app/tile/ContainerComponent.Template.html'
export class ContainerComponent implements OnInit {
@Input() tile: any;
@ViewChild(DynamicComponentHostDirective ) componentHost: DynamicComponentHostDirective ;
constructor(private _componentFactoryResolver: ComponentFactoryResolver,private dynamicComponentService :DynamicComponentService ) {
ngOnInit() {

ngAfterViewInit() {
renderComponents() {
let component=this.dynamicComponentService .getComponent(this.tile.componentName);
let componentFactory = this._componentFactoryResolver.resolveComponentFactory(component);
let viewContainerRef = this.componentHost.viewContainerRef;
let componentRef = viewContainerRef.createComponent(componentFactory);
(componentRef.instance).data = this.tile;
export interface YourInputDataModel {
data: any;

You can see I have applied the directive we have created before to the ng-template


This is a simple angular service factory to register the component you want to load at runtime.

//register your component
export class DynamicComponentService {
getComponent(componentName:string) {
return YourDynamicComponent
else if(componentName==="OtherComponent"){
return OtherComponent

YourDynamicComponent(Component we registered inside the factory loads dynamically )
import { Component, OnInit, Input, ReflectiveInjector, Injector } from '@angular/core';
selector: 'mydynamiccomponent',
templateUrl: 'app/templates/YourDynamicComponent.html'
export class YourDynamicComponent implements OnInit {
@Input() data: any;
constructor() {
ngOnInit() {


Entry Component

Finally to ensure that the compiler still generates a factory, add dynamically loaded components to the NgModule’s entryComponents array. You can add this in to your app module

imports: [BrowserModule,HttpModule],
providers: [DynamicComponentService],
declarations: [

exports: [],
entryComponents: [YourDynamicComponent,OtherComponent],
bootstrap: [MainApplicationComponent]
export class AppModule {
constructor() {


Source Code
Download Source

Communicating with parent component from child component in Angular 2+

In my last blog I have explained about @Input decorator to pass data from parent component to the child component. @Output is on other hand used in response to some event within a child component to receive some information for the parent component through some events. If you are not read my previous blog , I would suggest you to read the same. I have used the same example here also.

Child Component
Let’s talk about the child component first. You can see I have a simple method named productCardClick() which I am calling when clicking on the button. It’s pretty straight forward.

Modifying the child component
Next I am going to pass some data to the parent through the same productCardClick() method in the child component. In order to do that first you have to add a new property of type EventEmitter and emit the data you want to pass in to the parent component through this property like below .

Parent Component
Let’s go the parent component named ProductListComponent

In the parent component (ProductListComponent) you can see I have receiver method named onProductCardClickHandled(data:any) with a parameter to receive the data from the child component and I am calling this receiver method with a parameter via the @Output decorated property onProductCardClick inside the child component. Now when you click the button you will receive the child component data in to the parent component