Entity.CreateOrUpdateAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| CreateOrUpdateAsync(AtlasEntityWithExtInfo, Nullable<BusinessAttributeUpdateBehavior>, String, CancellationToken) |
Create or update an entity. Existing entity is matched using its unique guid if supplied or by its unique attributes eg: qualifiedName. Map and array of collections are not well supported. E.g., array<array<int>>, array<map<string, int>>. For each contact type, the maximum number of contacts is 20. |
| CreateOrUpdateAsync(RequestContent, String, String, RequestContext) |
[Protocol Method] Create or update an entity. Existing entity is matched using its unique guid if supplied or by its unique attributes eg: qualifiedName. Map and array of collections are not well supported. E.g., array<array<int>>, array<map<string, int>>. For each contact type, the maximum number of contacts is 20.
|
CreateOrUpdateAsync(AtlasEntityWithExtInfo, Nullable<BusinessAttributeUpdateBehavior>, String, CancellationToken)
- Source:
- Entity.cs
Create or update an entity. Existing entity is matched using its unique guid if supplied or by its unique attributes eg: qualifiedName. Map and array of collections are not well supported. E.g., array<array<int>>, array<map<string, int>>. For each contact type, the maximum number of contacts is 20.
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.EntityMutationResult>> CreateOrUpdateAsync(Azure.Analytics.Purview.DataMap.AtlasEntityWithExtInfo body, Azure.Analytics.Purview.DataMap.BusinessAttributeUpdateBehavior? businessAttributeUpdateBehavior = default, string collectionId = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateOrUpdateAsync : Azure.Analytics.Purview.DataMap.AtlasEntityWithExtInfo * Nullable<Azure.Analytics.Purview.DataMap.BusinessAttributeUpdateBehavior> * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.EntityMutationResult>>
override this.CreateOrUpdateAsync : Azure.Analytics.Purview.DataMap.AtlasEntityWithExtInfo * Nullable<Azure.Analytics.Purview.DataMap.BusinessAttributeUpdateBehavior> * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.EntityMutationResult>>
Public Overridable Function CreateOrUpdateAsync (body As AtlasEntityWithExtInfo, Optional businessAttributeUpdateBehavior As Nullable(Of BusinessAttributeUpdateBehavior) = Nothing, Optional collectionId As String = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of EntityMutationResult))
Parameters
Body parameter.
- businessAttributeUpdateBehavior
- Nullable<BusinessAttributeUpdateBehavior>
Used to define the update behavior for business attributes when updating entities.
- collectionId
- String
The collection where entities will be moved to. Only specify a value if you need to move an entity to another collection.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
body is null.
Examples
This sample shows how to call CreateOrUpdateAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
Entity client = new DataMapClient(endpoint, credential).GetEntityClient(apiVersion: "2023-09-01");
AtlasEntityWithExtInfo body = new AtlasEntityWithExtInfo
{
ReferredEntities = { },
Entity = new AtlasEntity
{
Attributes =
{
["owner"] = BinaryData.FromObjectAsJson("ExampleOwner"),
["modifiedTime"] = BinaryData.FromObjectAsJson(0),
["createTime"] = BinaryData.FromObjectAsJson(0),
["qualifiedName"] = BinaryData.FromObjectAsJson("https://exampleaccount.core.windows.net"),
["name"] = BinaryData.FromObjectAsJson("ExampleStorageAccount"),
["description"] = null,
["publicAccessLevel"] = null
},
TypeName = "azure_storage_account",
CustomAttributes =
{
["custAttr1"] = "attr1",
["custAttr2"] = "attr2"
},
},
};
Response<EntityMutationResult> response = await client.CreateOrUpdateAsync(body);
This sample shows how to call CreateOrUpdateAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
Entity client = new DataMapClient(endpoint, credential).GetEntityClient(apiVersion: "2023-09-01");
AtlasEntityWithExtInfo body = new AtlasEntityWithExtInfo
{
ReferredEntities = { },
Entity = new AtlasEntity
{
Attributes =
{
["owner"] = BinaryData.FromObjectAsJson("ExampleOwner"),
["modifiedTime"] = BinaryData.FromObjectAsJson(0),
["createTime"] = BinaryData.FromObjectAsJson(0),
["qualifiedName"] = BinaryData.FromObjectAsJson("https://exampleaccount.core.windows.net"),
["name"] = BinaryData.FromObjectAsJson("ExampleStorageAccount"),
["description"] = null,
["publicAccessLevel"] = null
},
TypeName = "azure_storage_account",
CreatedBy = "ExampleCreator",
Status = EntityStatus.Active,
UpdatedBy = "ExampleUpdator",
Version = 0L,
Contacts =
{
["Expert"] = new ContactInfo[]
{
new ContactInfo
{
Id = "30435ff9-9b96-44af-a5a9-e05c8b1ae2df",
Info = "Example Expert Info",
}
},
["Owner"] = new ContactInfo[]
{
new ContactInfo
{
Id = "30435ff9-9b96-44af-a5a9-e05c8b1ae2df",
Info = "Example Owner Info",
}
}
},
},
};
Response<EntityMutationResult> response = await client.CreateOrUpdateAsync(body);
This sample shows how to call CreateOrUpdateAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
Entity client = new DataMapClient(endpoint, credential).GetEntityClient(apiVersion: "2023-09-01");
AtlasEntityWithExtInfo body = new AtlasEntityWithExtInfo
{
ReferredEntities = { },
Entity = new AtlasEntity
{
Attributes =
{
["owner"] = BinaryData.FromObjectAsJson("ExampleOwner"),
["modifiedTime"] = BinaryData.FromObjectAsJson(0),
["createTime"] = BinaryData.FromObjectAsJson(0),
["qualifiedName"] = BinaryData.FromObjectAsJson("https://exampleaccount.core.windows.net"),
["name"] = BinaryData.FromObjectAsJson("ExampleStorageAccount"),
["description"] = null,
["userDescription"] = BinaryData.FromObjectAsJson("<div><b>testing</b></div>"),
["publicAccessLevel"] = null
},
TypeName = "azure_storage_account",
CreatedBy = "ExampleCreator",
CustomAttributes =
{
["microsoft_isDescriptionRichText"] = "true"
},
Status = EntityStatus.Active,
UpdatedBy = "ExampleUpdator",
Version = 0L,
},
};
Response<EntityMutationResult> response = await client.CreateOrUpdateAsync(body);
This sample shows how to call CreateOrUpdateAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
Entity client = new DataMapClient(endpoint, credential).GetEntityClient(apiVersion: "2023-09-01");
AtlasEntityWithExtInfo body = new AtlasEntityWithExtInfo
{
ReferredEntities = { },
Entity = new AtlasEntity
{
Attributes =
{
["owner"] = BinaryData.FromObjectAsJson("ExampleOwner"),
["modifiedTime"] = BinaryData.FromObjectAsJson(0),
["createTime"] = BinaryData.FromObjectAsJson(0),
["qualifiedName"] = BinaryData.FromObjectAsJson("exampleaccount"),
["name"] = BinaryData.FromObjectAsJson("ExampleStorageAccount"),
["description"] = null,
["publicAccessLevel"] = null
},
TypeName = "azure_storage_account",
CreatedBy = "ExampleCreator",
Status = EntityStatus.Active,
UpdatedBy = "ExampleUpdator",
Version = 0L,
Contacts =
{
["Expert"] = new ContactInfo[]
{
new ContactInfo
{
Id = "30435ff9-9b96-44af-a5a9-e05c8b1ae2df",
Info = "Example Expert Info",
}
},
["Owner"] = new ContactInfo[]
{
new ContactInfo
{
Id = "30435ff9-9b96-44af-a5a9-e05c8b1ae2df",
Info = "Example Owner Info",
}
}
},
},
};
Response<EntityMutationResult> response = await client.CreateOrUpdateAsync(body);
Applies to
CreateOrUpdateAsync(RequestContent, String, String, RequestContext)
- Source:
- Entity.cs
[Protocol Method] Create or update an entity. Existing entity is matched using its unique guid if supplied or by its unique attributes eg: qualifiedName. Map and array of collections are not well supported. E.g., array<array<int>>, array<map<string, int>>. For each contact type, the maximum number of contacts is 20.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler CreateOrUpdateAsync(AtlasEntityWithExtInfo, Nullable<BusinessAttributeUpdateBehavior>, String, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Response> CreateOrUpdateAsync(Azure.Core.RequestContent content, string businessAttributeUpdateBehavior = default, string collectionId = default, Azure.RequestContext context = default);
abstract member CreateOrUpdateAsync : Azure.Core.RequestContent * string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.CreateOrUpdateAsync : Azure.Core.RequestContent * string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function CreateOrUpdateAsync (content As RequestContent, Optional businessAttributeUpdateBehavior As String = Nothing, Optional collectionId As String = Nothing, Optional context As RequestContext = Nothing) As Task(Of Response)
Parameters
- content
- RequestContent
The content to send as the body of the request.
- businessAttributeUpdateBehavior
- String
Used to define the update behavior for business attributes when updating entities. Allowed values: "ignore" | "replace" | "merge"
- collectionId
- String
The collection where entities will be moved to. Only specify a value if you need to move an entity to another collection.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The response returned from the service.
Exceptions
content is null.
Service returned a non-success status code.
Examples
This sample shows how to call CreateOrUpdateAsync and parse the result.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
Entity client = new DataMapClient(endpoint, credential).GetEntityClient(apiVersion: "2023-09-01");
using RequestContent content = RequestContent.Create(new
{
referredEntities = new object(),
entity = new
{
typeName = "azure_storage_account",
attributes = new
{
owner = "ExampleOwner",
modifiedTime = 0,
createTime = 0,
qualifiedName = "https://exampleaccount.core.windows.net",
name = "ExampleStorageAccount",
},
customAttributes = new
{
custAttr1 = "attr1",
custAttr2 = "attr2",
},
},
});
Response response = await client.CreateOrUpdateAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.ToString());
This sample shows how to call CreateOrUpdateAsync and parse the result.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
Entity client = new DataMapClient(endpoint, credential).GetEntityClient(apiVersion: "2023-09-01");
using RequestContent content = RequestContent.Create(new
{
referredEntities = new object(),
entity = new
{
typeName = "azure_storage_account",
attributes = new
{
owner = "ExampleOwner",
modifiedTime = 0,
createTime = 0,
qualifiedName = "https://exampleaccount.core.windows.net",
name = "ExampleStorageAccount",
},
contacts = new
{
Expert = new object[]
{
new
{
id = "30435ff9-9b96-44af-a5a9-e05c8b1ae2df",
info = "Example Expert Info",
}
},
Owner = new object[]
{
new
{
id = "30435ff9-9b96-44af-a5a9-e05c8b1ae2df",
info = "Example Owner Info",
}
},
},
status = "ACTIVE",
createdBy = "ExampleCreator",
updatedBy = "ExampleUpdator",
version = 0L,
},
});
Response response = await client.CreateOrUpdateAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.ToString());
This sample shows how to call CreateOrUpdateAsync and parse the result.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
Entity client = new DataMapClient(endpoint, credential).GetEntityClient(apiVersion: "2023-09-01");
using RequestContent content = RequestContent.Create(new
{
referredEntities = new object(),
entity = new
{
typeName = "azure_storage_account",
attributes = new
{
owner = "ExampleOwner",
modifiedTime = 0,
createTime = 0,
qualifiedName = "https://exampleaccount.core.windows.net",
name = "ExampleStorageAccount",
userDescription = "<div><b>testing</b></div>",
},
customAttributes = new
{
microsoft_isDescriptionRichText = "true",
},
status = "ACTIVE",
createdBy = "ExampleCreator",
updatedBy = "ExampleUpdator",
version = 0L,
},
});
Response response = await client.CreateOrUpdateAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.ToString());
This sample shows how to call CreateOrUpdateAsync and parse the result.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
Entity client = new DataMapClient(endpoint, credential).GetEntityClient(apiVersion: "2023-09-01");
using RequestContent content = RequestContent.Create(new
{
referredEntities = new object(),
entity = new
{
typeName = "azure_storage_account",
attributes = new
{
owner = "ExampleOwner",
modifiedTime = 0,
createTime = 0,
qualifiedName = "exampleaccount",
name = "ExampleStorageAccount",
},
contacts = new
{
Expert = new object[]
{
new
{
id = "30435ff9-9b96-44af-a5a9-e05c8b1ae2df",
info = "Example Expert Info",
}
},
Owner = new object[]
{
new
{
id = "30435ff9-9b96-44af-a5a9-e05c8b1ae2df",
info = "Example Owner Info",
}
},
},
status = "ACTIVE",
createdBy = "ExampleCreator",
updatedBy = "ExampleUpdator",
version = 0L,
},
});
Response response = await client.CreateOrUpdateAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.ToString());