Create MongoDb User with Shell

Creating a user in MongoDB using createUser method.

user: "yourusername",
pwd: "yourpassword",
roles: [{role: "readWrite", db: "Talent-Dev"}]

Posted by justinpham, 0 comments

How to return Promise after dispatching with Redux Thunk

It’s very common to use Promise with Redux Thunk, it sounds complicated but it simply just returns Promise.resolve(data) after dispatching to the reducers. Here is an example in the redux action to signup new user, then on Client just uses then(result) to manipulate the screen logic

export const signUpUser = user => {
return dispatch => {
return fetch(``, {
method: "post",
headers: {
"Content-Type": "application/json",
Accept: "json"
body: JSON.stringify(user)
.then(res => res.json())
.then(data => {
if (data.isSuccess) {
payload: data.token
payload: data.tokenExpiredOn
return Promise.resolve(data);
.catch(error => {
return Promise.reject(error);

Posted by justinpham in .NET Core, AI, React - Redux, Solution Architecture, 0 comments

React-navigation 3 update the App container

There are some new changes with new react-navigation which is the main navigation system used in React Native app. The significant change which may affect your app is the app container. The app container is responsible for managing app state and linking the top-level navigator to the app environment.

import { createAppContainer } from 'react-navigation';
// you can also import from @react-navigation/native

const AppNavigator = createStackNavigator(...);

const AppContainer = createAppContainer(AppNavigator);

The AppContainer now becomes the main component loaded in the App.js without any wrapping view.

Posted by justinpham, 0 comments
Error: This experience uses an unsupported version of Expo. You may need to update Expo Client on your device.

Error: This experience uses an unsupported version of Expo. You may need to update Expo Client on your device.

Sometime when Expo releases new update with new features, you may have the issue of Expo Client expired when you run your app on Simulator. What you should do it restarts the simulator (Hardward > Restart), deleted Expo app on Simulator and run the application again. Next time when you run, it will install latest Expo client to the Simulator.

Posted by justinpham, 0 comments
Getting state error: undefined is not an object in a function

Getting state error: undefined is not an object in a function

There is a quite common issue with developers who just starting to use ReactJs. The junior and intermediate developers my team always have the issue undefined is not an object when they use this.state.[statement] in function. The problem is in Javascript in general, you need to pass the context of the App to use this keyword in the function. Most of the cases which cause the problem is developer don’t use the constructor way to declare the function which is this.function = this.function.bind(this)

Posted by justinpham, 0 comments

Azure Kubernetes Service (AKS) dashboard access error “forbidden”

There is a very common error when accessing Kubernetes Dashboard via proxy from remote machine. You can solve this error easily by granting ClusterRole to allow access to the dashboard

Create new file and insert following details

nano k8s-dashboard-access.yaml

kind: ClusterRoleBinding
name: kubernetes-dashboard
k8s-app: kubernetes-dashboard
kind: ClusterRole
name: cluster-admin
- kind: ServiceAccount
name: kubernetes-dashboard
namespace: kube-system

kubectl create -f kube-dashboard-access.yaml

Posted by justinpham, 0 comments

Disable check-in on TFS

As we all know that TFS is a centralised source code repository, it means everyone has access to the same source code repository. It causes lots of issues, especially when the new check-in breaks the existing code.
To implement Continuous Integration properly, the lead developer needs to setup code reviewing policy which is not allowed junior and intermediate developers check-in directly to the source code. The most effective to do it is disabling check-in permission for the normal group of developers.

Source Code Explorer -> Right click to Project and select Security

It will open TFS Web portal and disable the check-in policy for certain group of users on TFS

Posted by justinpham, 0 comments
Solution: The source file name(s) are larger than is supported by the file system

Solution: The source file name(s) are larger than is supported by the file system

When you develop application with Node.Js application, there is a very common issue with babel-cli or some other packages installed in node_modules cannot be deleted.

The easiest way to remove the folder with large source path or file name is using Git-bash on Windows or Linux

rm -rf folder-to-be-deleted

Problem solved

Posted by justinpham, 0 comments

Communication between Microservices

There are a number of discussions currently in the Dev forums and meetups about Microservices. From my point of view, it’s not a silver bullet that can solve all the problems with scalability, architecture. However, if it’s implemented correctly from architecture to coding level, it will have advantages in scaling, performance and easy deployment.

There are some similarities of Microservices and SOA with decoupled components. When I designed the SOA for the previous project, the data storage is shared within all services in SOA, it’s a very typical design of Restful API. However, the microservices have independent data storage for each service.

This post is more for the communication between microservice which normally the most confused when architect start implementing microservice.

Posted by justinpham, 0 comments

Self-hosted TFS Linux Build agent for Docker – The type initializer for ‘’ threw an exception

In the previous post that I demonstrated how to create a Self-hosted Build Agent on Windows. As I implemented Docker integration to the CI/CD DevOp pipeline on TFS, I need to make sure my build agent can build and push Docker image to Registry. The simple option is to installing Docker to our VM Windows Server, however, there are lots of issues to run Docker Windows on top of VM. I decided to create Linux VM for build agent and install Docker into it.

Following the same instructions to create build agent on Windows. The only issue is to run the on Linux, it throws an System.Net.Http.CurlHandler due to missing OpenSSL. The following approach can work for both Linux or MacOS.

brew update
brew install openssl
mkdir -p /usr/local/lib
sudo ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/

then install the agent again

~/myagent$ ./

To run Agent as a Service:

sudo su
./ install
./ run

Then you just need to install Docker on Linux by using following commands.

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] xenial stable"
sudo apt-get update

apt-cache search docker-ce

sudo apt-get install docker-ce

Test if Docker is running with the following command

docker run hello-world

Permission issue when running docker with the build agent

Assign $USER to docker group
sudo usermod -a -G docker $USER
systemctl start docker
gpasswd -a $USER docker

** To build .NET Core application with Linux build, you need to install Java (for getting the source code) and .NET Core Sdk
wget -q
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get install dotnet-sdk-2.1

Install Java

sudo add-apt-repository ppa:webupd8team/java
sudo apt update; sudo apt install oracle-java8-installer

Posted by justinpham, 0 comments