This blog will tell you how to add and retrieve web property bag through SharePoint CSOM.
I tried use Add method to insert a new property; however, it does not really add the new property.
Add Property
private int SetProperty(ClientContext clientContext, int flag)
{
Web web = clientContext.Site.RootWeb;
/* Add successfully, but not persistantly. Cannot find this new property when retrieve property bag clientContext.Load(web, w=>web.AppProperties);
clientContext.ExecuteQuery();
if (!web.AllProperties.FieldValues.ContainsKey("Customized"))
{
web.AllProperties.FieldValues.Add("Customized", flag);
}
else
{
web.AllProperties["Customized"] = flag;
}
*/// Correct Approach
var allProperties = web.AllProperties;
allProperties["CIBCCustomized"] = flag;
web.Update();
clientContext.ExecuteQuery();
return flag;
}
Retrieve Property
private int GetFlag(ClientContext clientContext)
{
Web web = clientContext.Site.RootWeb;
clientContext.Load(web, w => w.AllProperties);
clientContext.ExecuteQuery();
if (!web.AllProperties.FieldValues.ContainsKey("Customized"))
{
return 0;
}
else
{
return (int)web.AllProperties["Customized"];
}
}

