EasmClient.CreateOrReplaceDataConnection 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
CreateOrReplaceDataConnection(String, DataConnectionPayload, CancellationToken) |
Create or replace a data connection with a given dataConnectionName. |
CreateOrReplaceDataConnection(String, RequestContent, RequestContext) |
[Protocol Method] Create or replace a data connection with a given dataConnectionName.
|
CreateOrReplaceDataConnection(String, DataConnectionPayload, CancellationToken)
- Source:
- EasmClient.cs
Create or replace a data connection with a given dataConnectionName.
public virtual Azure.Response<Azure.Analytics.Defender.Easm.DataConnection> CreateOrReplaceDataConnection (string dataConnectionName, Azure.Analytics.Defender.Easm.DataConnectionPayload dataConnectionPayload, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateOrReplaceDataConnection : string * Azure.Analytics.Defender.Easm.DataConnectionPayload * System.Threading.CancellationToken -> Azure.Response<Azure.Analytics.Defender.Easm.DataConnection>
override this.CreateOrReplaceDataConnection : string * Azure.Analytics.Defender.Easm.DataConnectionPayload * System.Threading.CancellationToken -> Azure.Response<Azure.Analytics.Defender.Easm.DataConnection>
Public Overridable Function CreateOrReplaceDataConnection (dataConnectionName As String, dataConnectionPayload As DataConnectionPayload, Optional cancellationToken As CancellationToken = Nothing) As 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 CreateOrReplaceDataConnection.
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 = client.CreateOrReplaceDataConnection("<dataConnectionName>", dataConnectionPayload);
This sample shows how to call CreateOrReplaceDataConnection 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 = client.CreateOrReplaceDataConnection("<dataConnectionName>", dataConnectionPayload);
Applies to
CreateOrReplaceDataConnection(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 CreateOrReplaceDataConnection(String, DataConnectionPayload, CancellationToken) convenience overload with strongly typed models first.
public virtual Azure.Response CreateOrReplaceDataConnection (string dataConnectionName, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateOrReplaceDataConnection : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.CreateOrReplaceDataConnection : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function CreateOrReplaceDataConnection (dataConnectionName As String, content As RequestContent, Optional context As RequestContext = Nothing) As 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 CreateOrReplaceDataConnection 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 = client.CreateOrReplaceDataConnection("<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 CreateOrReplaceDataConnection 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 = client.CreateOrReplaceDataConnection("<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