Atualize as opções de ajuste automático no servidor.
PATCH https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current?api-version=2025-01-01
Parâmetros do URI
| Name |
Em |
Obrigatório |
Tipo |
Descrição |
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
O nome do grupo de recursos. O nome não diferencia maiúsculas de minúsculas.
|
|
serverName
|
path |
True
|
string
|
O nome do servidor.
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
A ID da assinatura de destino. O valor deve ser um UUID.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
A versão da API a utilizar para esta operação.
|
Corpo do Pedido
Respostas
Segurança
azure_auth
Azure Active Directory OAuth2 Flow.
Tipo:
oauth2
Fluxo:
implicit
URL de Autorização:
https://login.microsoftonline.com/common/oauth2/authorize
Âmbitos
| Name |
Descrição |
|
user_impersonation
|
personificar a sua conta de utilizador
|
Exemplos
Updates server automatic tuning settings with all properties
Pedido de amostra
PATCH https://management.azure.com/subscriptions/c3aa9078-0000-0000-0000-e36f151182d7/resourceGroups/default-sql-onebox/providers/Microsoft.Sql/servers/testsvr11/automaticTuning/current?api-version=2025-01-01
{
"properties": {
"desiredState": "Auto",
"options": {
"createIndex": {
"desiredState": "Off"
},
"dropIndex": {
"desiredState": "On"
},
"forceLastGoodPlan": {
"desiredState": "Default"
}
}
}
}
import com.azure.resourcemanager.sql.fluent.models.ServerAutomaticTuningInner;
import com.azure.resourcemanager.sql.models.AutomaticTuningOptionModeDesired;
import com.azure.resourcemanager.sql.models.AutomaticTuningServerMode;
import com.azure.resourcemanager.sql.models.AutomaticTuningServerOptions;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ServerAutomaticTuning Update.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/ServerAutomaticTuningUpdateMax.json
*/
/**
* Sample code: Updates server automatic tuning settings with all properties.
*
* @param manager Entry point to SqlServerManager.
*/
public static void
updatesServerAutomaticTuningSettingsWithAllProperties(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getServerAutomaticTunings().updateWithResponse("default-sql-onebox", "testsvr11",
new ServerAutomaticTuningInner().withDesiredState(AutomaticTuningServerMode.AUTO)
.withOptions(mapOf("createIndex",
new AutomaticTuningServerOptions().withDesiredState(AutomaticTuningOptionModeDesired.OFF),
"dropIndex",
new AutomaticTuningServerOptions().withDesiredState(AutomaticTuningOptionModeDesired.ON),
"forceLastGoodPlan",
new AutomaticTuningServerOptions().withDesiredState(AutomaticTuningOptionModeDesired.DEFAULT))),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python server_automatic_tuning_update_max.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.server_automatic_tuning.update(
resource_group_name="default-sql-onebox",
server_name="testsvr11",
parameters={
"properties": {
"desiredState": "Auto",
"options": {
"createIndex": {"desiredState": "Off"},
"dropIndex": {"desiredState": "On"},
"forceLastGoodPlan": {"desiredState": "Default"},
},
}
},
)
print(response)
# x-ms-original-file: 2025-01-01/ServerAutomaticTuningUpdateMax.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to update automatic tuning options on server.
*
* @summary update automatic tuning options on server.
* x-ms-original-file: 2025-01-01/ServerAutomaticTuningUpdateMax.json
*/
async function updatesServerAutomaticTuningSettingsWithAllProperties() {
const credential = new DefaultAzureCredential();
const subscriptionId = "c3aa9078-0000-0000-0000-e36f151182d7";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.serverAutomaticTuningOperations.update(
"default-sql-onebox",
"testsvr11",
{
desiredState: "Auto",
options: {
createIndex: { desiredState: "Off" },
dropIndex: { desiredState: "On" },
forceLastGoodPlan: { desiredState: "Default" },
},
},
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/ServerAutomaticTuningUpdateMax.json
// this example is just showing the usage of "ServerAutomaticTuning_Update" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SqlServerAutomaticTuningResource created on azure
// for more information of creating SqlServerAutomaticTuningResource, please refer to the document of SqlServerAutomaticTuningResource
string subscriptionId = "c3aa9078-0000-0000-0000-e36f151182d7";
string resourceGroupName = "default-sql-onebox";
string serverName = "testsvr11";
ResourceIdentifier sqlServerAutomaticTuningResourceId = SqlServerAutomaticTuningResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerAutomaticTuningResource sqlServerAutomaticTuning = client.GetSqlServerAutomaticTuningResource(sqlServerAutomaticTuningResourceId);
// invoke the operation
SqlServerAutomaticTuningData data = new SqlServerAutomaticTuningData
{
DesiredState = AutomaticTuningServerMode.Auto,
Options =
{
["createIndex"] = new AutomaticTuningServerOptions
{
DesiredState = AutomaticTuningOptionModeDesired.Off,
},
["dropIndex"] = new AutomaticTuningServerOptions
{
DesiredState = AutomaticTuningOptionModeDesired.On,
},
["forceLastGoodPlan"] = new AutomaticTuningServerOptions
{
DesiredState = AutomaticTuningOptionModeDesired.Default,
}
},
};
SqlServerAutomaticTuningResource result = await sqlServerAutomaticTuning.UpdateAsync(data);
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SqlServerAutomaticTuningData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"name": "current",
"type": "Microsoft.Sql/servers/automaticTuning",
"id": "/subscriptions/c3aa9078-0000-0000-0000-e36f151182d7/resourceGroups/default-sql-onebox/providers/Microsoft.Sql/servers/testsvr11/automaticTuning/current",
"properties": {
"actualState": "Auto",
"desiredState": "Auto",
"options": {
"createIndex": {
"actualState": "Off",
"desiredState": "Off"
},
"dropIndex": {
"actualState": "On",
"desiredState": "On"
},
"forceLastGoodPlan": {
"actualState": "On",
"desiredState": "Default",
"reasonCode": 2,
"reasonDesc": "AutoConfigured"
},
"maintainIndex": {
"actualState": "Off",
"desiredState": "Default",
"reasonCode": 2,
"reasonDesc": "AutoConfigured"
}
}
}
}
Updates server automatic tuning settings with minimal properties
Pedido de amostra
PATCH https://management.azure.com/subscriptions/c3aa9078-0000-0000-0000-e36f151182d7/resourceGroups/default-sql-onebox/providers/Microsoft.Sql/servers/testsvr11/automaticTuning/current?api-version=2025-01-01
{
"properties": {
"desiredState": "Auto"
}
}
import com.azure.resourcemanager.sql.fluent.models.ServerAutomaticTuningInner;
import com.azure.resourcemanager.sql.models.AutomaticTuningServerMode;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ServerAutomaticTuning Update.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/ServerAutomaticTuningUpdateMin.json
*/
/**
* Sample code: Updates server automatic tuning settings with minimal properties.
*
* @param manager Entry point to SqlServerManager.
*/
public static void updatesServerAutomaticTuningSettingsWithMinimalProperties(
com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getServerAutomaticTunings().updateWithResponse("default-sql-onebox", "testsvr11",
new ServerAutomaticTuningInner().withDesiredState(AutomaticTuningServerMode.AUTO),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python server_automatic_tuning_update_min.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.server_automatic_tuning.update(
resource_group_name="default-sql-onebox",
server_name="testsvr11",
parameters={"properties": {"desiredState": "Auto"}},
)
print(response)
# x-ms-original-file: 2025-01-01/ServerAutomaticTuningUpdateMin.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to update automatic tuning options on server.
*
* @summary update automatic tuning options on server.
* x-ms-original-file: 2025-01-01/ServerAutomaticTuningUpdateMin.json
*/
async function updatesServerAutomaticTuningSettingsWithMinimalProperties() {
const credential = new DefaultAzureCredential();
const subscriptionId = "c3aa9078-0000-0000-0000-e36f151182d7";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.serverAutomaticTuningOperations.update(
"default-sql-onebox",
"testsvr11",
{ desiredState: "Auto" },
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/ServerAutomaticTuningUpdateMin.json
// this example is just showing the usage of "ServerAutomaticTuning_Update" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SqlServerAutomaticTuningResource created on azure
// for more information of creating SqlServerAutomaticTuningResource, please refer to the document of SqlServerAutomaticTuningResource
string subscriptionId = "c3aa9078-0000-0000-0000-e36f151182d7";
string resourceGroupName = "default-sql-onebox";
string serverName = "testsvr11";
ResourceIdentifier sqlServerAutomaticTuningResourceId = SqlServerAutomaticTuningResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerAutomaticTuningResource sqlServerAutomaticTuning = client.GetSqlServerAutomaticTuningResource(sqlServerAutomaticTuningResourceId);
// invoke the operation
SqlServerAutomaticTuningData data = new SqlServerAutomaticTuningData
{
DesiredState = AutomaticTuningServerMode.Auto,
};
SqlServerAutomaticTuningResource result = await sqlServerAutomaticTuning.UpdateAsync(data);
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SqlServerAutomaticTuningData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Resposta da amostra
{
"name": "current",
"type": "Microsoft.Sql/servers/automaticTuning",
"id": "/subscriptions/c3aa9078-0000-0000-0000-e36f151182d7/resourceGroups/default-sql-onebox/providers/Microsoft.Sql/servers/testsvr11/automaticTuning/current",
"properties": {
"actualState": "Auto",
"desiredState": "Auto",
"options": {
"createIndex": {
"actualState": "On",
"desiredState": "Default",
"reasonCode": 2,
"reasonDesc": "AutoConfigured"
},
"dropIndex": {
"actualState": "Off",
"desiredState": "Default",
"reasonCode": 2,
"reasonDesc": "AutoConfigured"
},
"forceLastGoodPlan": {
"actualState": "On",
"desiredState": "Default",
"reasonCode": 2,
"reasonDesc": "AutoConfigured"
},
"maintainIndex": {
"actualState": "Off",
"desiredState": "Default",
"reasonCode": 2,
"reasonDesc": "AutoConfigured"
}
}
}
}
Definições
AutomaticTuningOptionModeActual
Enumeração
Estado real da opção de ajuste automático.
| Valor |
Descrição |
|
Off
|
Off
|
|
On
|
Ligado
|
AutomaticTuningOptionModeDesired
Enumeração
Opção de ajuste automático estado desejado.
| Valor |
Descrição |
|
Off
|
Off
|
|
On
|
Ligado
|
|
Default
|
Predefinição
|
AutomaticTuningServerMode
Enumeração
Ajuste automático do estado desejado.
| Valor |
Descrição |
|
Custom
|
Personalizado
|
|
Auto
|
Automático
|
|
Unspecified
|
Não especificado
|
AutomaticTuningServerOptions
Object
Propriedades de ajuste automático para consultores individuais.
AutomaticTuningServerReason
Enumeração
A descrição do motivo, se desejado, e o estado real são diferentes.
| Valor |
Descrição |
|
Default
|
Predefinição
|
|
Disabled
|
Disabled
|
|
AutoConfigured
|
AutoConfigurado
|
createdByType
Enumeração
O tipo de identidade que criou o recurso.
| Valor |
Descrição |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
ErrorAdditionalInfo
Object
O erro de gerenciamento de recursos informações adicionais.
| Name |
Tipo |
Descrição |
|
info
|
object
|
As informações adicionais.
|
|
type
|
string
|
O tipo de informação adicional.
|
ErrorDetail
Object
O detalhe do erro.
| Name |
Tipo |
Descrição |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
O erro informações adicionais.
|
|
code
|
string
|
O código de erro.
|
|
details
|
ErrorDetail[]
|
Os detalhes do erro.
|
|
message
|
string
|
A mensagem de erro.
|
|
target
|
string
|
O alvo do erro.
|
ErrorResponse
Object
Resposta de erro
| Name |
Tipo |
Descrição |
|
error
|
ErrorDetail
|
O objeto de erro.
|
ServerAutomaticTuning
Object
Sintonização automática no nível do servidor.
| Name |
Tipo |
Descrição |
|
id
|
string
(arm-id)
|
ID de recurso totalmente qualificado para o recurso. Por exemplo, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
name
|
string
|
O nome do recurso
|
|
properties.actualState
|
AutomaticTuningServerMode
|
Ajuste automático do estado real.
|
|
properties.desiredState
|
AutomaticTuningServerMode
|
Ajuste automático do estado desejado.
|
|
properties.options
|
<string,
AutomaticTuningServerOptions>
|
Definição automática de opções de ajuste.
|
|
systemData
|
systemData
|
Metadados do Azure Resource Manager contendo informações createdBy e modifiedBy.
|
|
type
|
string
|
O tipo do recurso. Por exemplo, "Microsoft. Computação/Máquinas Virtuais" ou "Microsoft. ContasArmazenamento/Armazenamento"
|
systemData
Object
Metadados referentes à criação e última modificação do recurso.
| Name |
Tipo |
Descrição |
|
createdAt
|
string
(date-time)
|
O carimbo de data/hora da criação de recursos (UTC).
|
|
createdBy
|
string
|
A identidade que criou o recurso.
|
|
createdByType
|
createdByType
|
O tipo de identidade que criou o recurso.
|
|
lastModifiedAt
|
string
(date-time)
|
O carimbo de data/hora da última modificação do recurso (UTC)
|
|
lastModifiedBy
|
string
|
A identidade que modificou o recurso pela última vez.
|
|
lastModifiedByType
|
createdByType
|
O tipo de identidade que modificou o recurso pela última vez.
|