EasmClient.CreateOrReplaceDataConnectionAsync 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
CreateOrReplaceDataConnectionAsync(String, DataConnectionPayload, CancellationToken) |
Create or replace a data connection with a given dataConnectionName. |
CreateOrReplaceDataConnectionAsync(String, RequestContent, RequestContext) |
[Protocol Method] Create or replace a data connection with a given dataConnectionName.
|
CreateOrReplaceDataConnectionAsync(String, DataConnectionPayload, CancellationToken)
- Source:
- EasmClient.cs
Create or replace a data connection with a given dataConnectionName.
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Defender.Easm.DataConnection>> CreateOrReplaceDataConnectionAsync (string dataConnectionName, Azure.Analytics.Defender.Easm.DataConnectionPayload dataConnectionPayload, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateOrReplaceDataConnectionAsync : string * Azure.Analytics.Defender.Easm.DataConnectionPayload * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Defender.Easm.DataConnection>>
override this.CreateOrReplaceDataConnectionAsync : string * Azure.Analytics.Defender.Easm.DataConnectionPayload * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Defender.Easm.DataConnection>>
Public Overridable Function CreateOrReplaceDataConnectionAsync (dataConnectionName As String, dataConnectionPayload As DataConnectionPayload, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of DataConnection))
Parameters
- dataConnectionName
- String
The caller provided unique name for the resource.
- dataConnectionPayload
- DataConnectionPayload
The DataConnectionPayload to use.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
dataConnectionName
or dataConnectionPayload
is null.
dataConnectionName
is an empty string, and was expected to be non-empty.
Examples
This sample shows how to call CreateOrReplaceDataConnectionAsync.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
EasmClient client = new EasmClient(endpoint, credential);
DataConnectionPayload dataConnectionPayload = new LogAnalyticsDataConnectionPayload(new LogAnalyticsDataConnectionProperties());
Response<DataConnection> response = await client.CreateOrReplaceDataConnectionAsync("<dataConnectionName>", dataConnectionPayload);
This sample shows how to call CreateOrReplaceDataConnectionAsync with all parameters.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
EasmClient client = new EasmClient(endpoint, credential);
DataConnectionPayload dataConnectionPayload = new LogAnalyticsDataConnectionPayload(new LogAnalyticsDataConnectionProperties
{
ApiKey = "<apiKey>",
WorkspaceId = "<workspaceId>",
})
{
Name = "<name>",
Content = DataConnectionContent.Assets,
Frequency = DataConnectionFrequency.Daily,
FrequencyOffset = 1234,
};
Response<DataConnection> response = await client.CreateOrReplaceDataConnectionAsync("<dataConnectionName>", dataConnectionPayload);
Applies to
CreateOrReplaceDataConnectionAsync(String, RequestContent, RequestContext)
- Source:
- EasmClient.cs
[Protocol Method] Create or replace a data connection with a given dataConnectionName.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler CreateOrReplaceDataConnectionAsync(String, DataConnectionPayload, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Response> CreateOrReplaceDataConnectionAsync (string dataConnectionName, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateOrReplaceDataConnectionAsync : string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.CreateOrReplaceDataConnectionAsync : string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function CreateOrReplaceDataConnectionAsync (dataConnectionName As String, content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of Response)
Parameters
- dataConnectionName
- String
The caller provided unique name for the resource.
- content
- RequestContent
The content to send as the body of the request.
- 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
dataConnectionName
or content
is null.
dataConnectionName
is an empty string, and was expected to be non-empty.
Service returned a non-success status code.
Examples
This sample shows how to call CreateOrReplaceDataConnectionAsync and parse the result.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
EasmClient client = new EasmClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
properties = new object(),
kind = "logAnalytics",
});
Response response = await client.CreateOrReplaceDataConnectionAsync("<dataConnectionName>", content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
Console.WriteLine(result.GetProperty("name").ToString());
This sample shows how to call CreateOrReplaceDataConnectionAsync with all parameters and request content and parse the result.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
EasmClient client = new EasmClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
properties = new
{
apiKey = "<apiKey>",
workspaceId = "<workspaceId>",
},
kind = "logAnalytics",
name = "<name>",
content = "assets",
frequency = "daily",
frequencyOffset = 1234,
});
Response response = await client.CreateOrReplaceDataConnectionAsync("<dataConnectionName>", content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
Console.WriteLine(result.GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("displayName").ToString());
Console.WriteLine(result.GetProperty("content").ToString());
Console.WriteLine(result.GetProperty("createdDate").ToString());
Console.WriteLine(result.GetProperty("frequency").ToString());
Console.WriteLine(result.GetProperty("frequencyOffset").ToString());
Console.WriteLine(result.GetProperty("updatedDate").ToString());
Console.WriteLine(result.GetProperty("userUpdatedAt").ToString());
Console.WriteLine(result.GetProperty("active").ToString());
Console.WriteLine(result.GetProperty("inactiveMessage").ToString());
Applies to
Azure SDK for .NET