First, you need to register the custom facet model:
public static class CustomerCollectionModel
{
public static XdbModel Model { get; } = CreateModel();
private static XdbModel CreateModel()
{
XdbModelBuilder builder = new XdbModelBuilder("CustomFacets.Xconnect.CustomerCollectionModel", new XdbModelVersion(1, 0));
builder.ReferenceModel(Sitecore.XConnect.Collection.Model.CollectionModel.Model);
builder.DefineFacet<Contact, CustomerStatus>(CustomerStatus.DefaultFacetKey);
return builder.BuildModel();
}
}
Then, You need to serialize the collection model in which you defined your custom facet model. To serialize into JSON using the below code:
var model = Sitecore.XConnect.Serialization.XdbModelWriter.Serialize(CustomerCollectionModel.Model);
File.WriteAllText(CustomerCollectionModel.Model.FullName + ".json", model);
On execution of the console application, it will generate a JSON file at bin/Release folder. Copy that JSON file and paste at the below places:
Deploy the JSON file to the below locations on Azure:
<Instance-Name>-xc-search -> App_Data/Models
<Instance-Name>-xc-search -> App_Data/jobs/continuous/IndexWorker/App_data/Models
<Instance-Name>-xc-collect -> App_Data/Models
<Instance-Name>-xc-refdata -> App_Data/Models
<Instance-Name>-ma-ops -> App_Data/Models
For more details, refer to this blogpost https://sitecorewithraman.wordpress.com/2021/06/06/deploying-xconnect-customizations-on-azure/