Compartir a través de


LoadTestRunClient.CreateOrUpdateAppComponents Método

Definición

Asocie un componente de aplicación (colección de recursos de Azure) a una ejecución de prueba.

public virtual Azure.Response CreateOrUpdateAppComponents (string testRunId, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateOrUpdateAppComponents : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.CreateOrUpdateAppComponents : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function CreateOrUpdateAppComponents (testRunId As String, content As RequestContent, Optional context As RequestContext = Nothing) As Response

Parámetros

testRunId
String

El nombre único de la ejecución de pruebas de carga debe contener solo caracteres alfabéticos, numéricos, de subrayado o guiones en minúsculas.

content
RequestContent

Contenido que se va a enviar como el cuerpo de la solicitud. Los detalles del esquema del cuerpo de la solicitud se encuentran en la sección Comentarios a continuación.

context
RequestContext

Contexto de solicitud, que puede invalidar los comportamientos predeterminados de la canalización de cliente por llamada.

Devoluciones

Respuesta devuelta desde el servicio. Los detalles del esquema del cuerpo de la respuesta se encuentran en la sección Comentarios a continuación.

Excepciones

testRunId o content es null.

testRunId es una cadena vacía y se espera que no esté vacía.

El servicio devolvió un código de estado no correcto.

Ejemplos

En este ejemplo se muestra cómo llamar a CreateOrUpdateAppComponents con los parámetros necesarios y solicitar contenido y analizar el resultado.

var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new LoadTestRunClient(endpoint, credential);

var data = new {
    components = new {
        key = new {
            resourceName = "<resourceName>",
            resourceType = "<resourceType>",
            displayName = "<displayName>",
            kind = "<kind>",
        },
    },
};

Response response = client.CreateOrUpdateAppComponents("<testRunId>", RequestContent.Create(data));

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("components").GetProperty("<test>").GetProperty("resourceId").ToString());
Console.WriteLine(result.GetProperty("components").GetProperty("<test>").GetProperty("resourceName").ToString());
Console.WriteLine(result.GetProperty("components").GetProperty("<test>").GetProperty("resourceType").ToString());
Console.WriteLine(result.GetProperty("components").GetProperty("<test>").GetProperty("displayName").ToString());
Console.WriteLine(result.GetProperty("components").GetProperty("<test>").GetProperty("resourceGroup").ToString());
Console.WriteLine(result.GetProperty("components").GetProperty("<test>").GetProperty("subscriptionId").ToString());
Console.WriteLine(result.GetProperty("components").GetProperty("<test>").GetProperty("kind").ToString());
Console.WriteLine(result.GetProperty("testRunId").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("createdBy").ToString());
Console.WriteLine(result.GetProperty("lastModifiedDateTime").ToString());
Console.WriteLine(result.GetProperty("lastModifiedBy").ToString());

Comentarios

A continuación se muestra el esquema JSON para las cargas de solicitud y respuesta.

Cuerpo de la solicitud:

Esquema para TestRunAppComponents:

{
  components: Dictionary<string, AppComponent>, # Required. Azure resource collection { resource id (fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) : resource object } 
  testRunId: string, # Optional. Test run identifier
  createdDateTime: string (ISO 8601 Format), # Optional. The creation datetime(ISO 8601 literal format).
  createdBy: string, # Optional. The user that created.
  lastModifiedDateTime: string (ISO 8601 Format), # Optional. The last Modified datetime(ISO 8601 literal format).
  lastModifiedBy: string, # Optional. The user that last modified.
}

Cuerpo de la respuesta:

Esquema para TestRunAppComponents:

{
  components: Dictionary<string, AppComponent>, # Required. Azure resource collection { resource id (fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) : resource object } 
  testRunId: string, # Optional. Test run identifier
  createdDateTime: string (ISO 8601 Format), # Optional. The creation datetime(ISO 8601 literal format).
  createdBy: string, # Optional. The user that created.
  lastModifiedDateTime: string (ISO 8601 Format), # Optional. The last Modified datetime(ISO 8601 literal format).
  lastModifiedBy: string, # Optional. The user that last modified.
}

Se aplica a