カスタム モデルのデプロイ
カスタム モデルをシリアル化して xConnect にデプロイする方法。
このトピックでは、カスタム モデルをシリアル化して xConnect にデプロイする方法について説明します。モデルのデプロイは、モデルの JSON 表現を xConnect のすべてのインスタンスに手動でコピーするプロセスです。
モデルを JSON にシリアル化するには:
xConnect モデルをシリアル化するコンソール アプリケーションを作成します。
モデルを JSON に、次の例のようにシリアル化します。この例では、Sitecore のデフォルトのコレクション モデルを使用しています。
using Sitecore.XConnect.Serialization; namespace Documentation { public class DeployModel { public void Serialize() { // File name will be Sitecore.XConnect.Collection.Model, 9.0.json var json = XdbModelWriter.Serialize(Sitecore.XConnect.Collection.Model.CollectionModel.Model); } } }
重要
ファイル名は変更しないでください。ファイル名は、モデル クラスで宣言されている名前と一致する必要があります。
モデルを xConnect および Marketing Automation Operations ロールにデプロイするには:
モデルの JSON ファイルを、xConnect Collection Search および xConnect Collection のロールのすべてのインスタンスに対して、次のパスにコピーします。
C:\<Path to xConnect>\root\App_Data\Models
モデルの JSON ファイルを、xConnect Search Indexer で次のパスにコピーします。
C:\<Path to indexer>\root\App_data\Models
注記
デフォルトでは、xConnect Search Indexer は
C:\<Path to xConnect>\App_data\jobs\continuous\IndexWorker
にあります。Sitecore 9.0 Update 2 以降では、Marketing Automation Operations ロールのすべてのインスタンスで、モデルの JSON ファイルを次のパスにコピーする必要があります。このモデルは、ライブ イベントを処理するために必要です。
C:\<Path to marketing automation operations>\root\App_Data\Models
注記
手順 3 は、Marketing Automation Operations のロールが xConnect Collection Search または xConnect Collection と組み合わされている場合は必要ありません。
カスタム モデル データをカスタム アクティビティ タイプのコンテキストで操作するには、次の手順を実行します。この機能は、9.0 Update-1 以降で使用できます。
Marketing Automation Engine にモデルをデプロイするには:
モデルの DLL を Marketing Automation Engine のすべてのインスタンスのルートにコピーします。
注記
Marketing Automation Engine には、モデルの JSON 表現は必要ありません。デフォルトでは、Marketing Automation Engine は
C:\<Path to xConnect>\App_data\jobs\continuous\AutomationEngine
にあります。C:\<Path to xConnect>\App_data\jobs\continuous\AutomationEngine\AppData\config\sitecore
で、構成ファイルをsc.Sample.CustomModel.xml
という名前で作成します。ファイル名は、sc
で始まり、.xml
で終わる必要があります。次のモデル構成を貼り付けて、以下のように変更します。TypeName
をモデルの完全修飾名に変更する。必要に応じて、
CustomModel1
ノードの名前を変更する。
<Settings> <Sitecore> <XConnect> <Services> <XConnect.Client.Configuration> <Options> <Models> <CustomModel1> <TypeName>Sitecore.Xdb.MarketingAutomation.Stub.Model.StubModel, Sitecore.Xdb.MarketingAutomation.Stub</TypeName> </CustomModel1> </Models> </Options> </XConnect.Client.Configuration> </Services> </XConnect> </Sitecore> </Settings>
このモデルは Model
という名前の静的プロパティを公開し、そこから XdbModel
をモデルに返すことを想定しています。このカスタム モデルが別の静的プロパティからモデルを公開する場合は、そのプロパティの名前を CustomModel
要素の内部にある PropertyName
要素に含めてください。
<Settings> <Sitecore> <XConnect> <Services> <XConnect.Client.Configuration> <Options> <Models> <CustomModel1> <TypeName>Sitecore.Xdb.MarketingAutomation.Stub.Model.StubModel, Sitecore.Xdb.MarketingAutomation.Stub</TypeName> <PropertyName>TheModel</PropertyName> </CustomModel1> </Models> </Options> </XConnect.Client.Configuration> </Services> </XConnect> </Sitecore> </Settings>
最後に、カスタム モデルをすべての core Sitecore インスタンスにデプロイする必要があります。これには次のロールが含まれます。
Content Delivery
Content Management
xDB Processing
core Sitecore インスタンスそれぞれに対し、次の操作を行います。
モデル DLL を core Sitecore インスタンスの bin ディレクトリにコピーします。
独自のモデル クラスを次のように
\App_Config\Sitecore\XConnect.Client.Configuration\Sitecore.XConnect.Client.config
に適用します。<?xml version="1.0" encoding="utf-8" ?> <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <xconnect> <runtime type="Sitecore.XConnect.Client.Configuration.RuntimeModelConfiguration,Sitecore.XConnect.Client.Configuration"> <schemas hint="list:AddModelConfiguration"> <!-- value of 'name' property must be unique --> <schema name="documentationmodel" type="Sitecore.XConnect.Client.Configuration.StaticModelConfiguration,Sitecore.XConnect.Client.Configuration" patch:after="schema[@name='collectionmodel']"> <param desc="modeltype">Documentation.Model.CollectionModel, Documentation.Model</param> </schema> </schemas> </runtime> </xconnect> </sitecore> </configuration>
コードで、モデルの DLL を参照します。
xConnect Client API を使用してイベントをトリガーするか、またはコンタクト ファセットにデータを入力します。
注記
Sitecore のコンテキスト外でモデルを使用することもできます。