你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Update-AzSqlVM

Updates a SQL virtual machine.

Syntax

Update-AzSqlVM
      -Name <String>
      -ResourceGroupName <String>
      [-SubscriptionId <String>]
      [-LicenseType <SqlServerLicenseType>]
      [-Offer <String>]
      [-Sku <SqlImageSku>]
      [-SqlManagementType <SqlManagementMode>]
      [-Tag <Hashtable>]
      [-AutoBackupSettingBackupScheduleType <BackupScheduleType>]
      [-AutoBackupSettingBackupSystemDb]
      [-AutoBackupSettingDaysOfWeek <AutoBackupDaysOfWeek[]>]
      [-AutoBackupSettingEnable]
      [-AutoBackupSettingEnableEncryption]
      [-AutoBackupSettingFullBackupFrequency <FullBackupFrequencyType>]
      [-AutoBackupSettingFullBackupStartTime <Int32>]
      [-AutoBackupSettingFullBackupWindowHour <Int32>]
      [-AutoBackupSettingLogBackupFrequency <Int32>]
      [-AutoBackupSettingPassword <SecureString>]
      [-AutoBackupSettingRetentionPeriod <Int32>]
      [-AutoBackupSettingStorageAccessKey <String>]
      [-AutoBackupSettingStorageAccountUrl <String>]
      [-AutoBackupSettingStorageContainerName <String>]
      [-AutoPatchingSettingDayOfWeek <DayOfWeek>]
      [-AutoPatchingSettingEnable]
      [-AutoPatchingSettingMaintenanceWindowDuration <Int32>]
      [-AutoPatchingSettingMaintenanceWindowStartingHour <Int32>]
      [-AssessmentSettingEnable]
      [-AssessmentSettingRunImmediately]
      [-ScheduleDayOfWeek <AssessmentDayOfWeek>]
      [-ScheduleEnable]
      [-ScheduleMonthlyOccurrence <Int32>]
      [-ScheduleStartTime <String>]
      [-ScheduleWeeklyInterval <Int32>]
      [-SqlVirtualMachineGroupResourceId <String>]
      [-VirtualMachineResourceId <String>]
      [-WsfcDomainCredentialsClusterBootstrapAccountPassword <SecureString>]
      [-WsfcDomainCredentialsClusterOperatorAccountPassword <SecureString>]
      [-WsfcDomainCredentialsSqlServiceAccountPassword <SecureString>]
      [-WsfcStaticIP <String>]
      [-EnableAutomaticUpgrade]
      [-ManagedIdentityClientId <String>]
      [-IdentityType <String>]
      [-DefaultProfile <PSObject>]
      [-AsJob]
      [-NoWait]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Update-AzSqlVM
      -InputObject <ISqlVirtualMachineIdentity>
      [-LicenseType <SqlServerLicenseType>]
      [-Offer <String>]
      [-Sku <SqlImageSku>]
      [-SqlManagementType <SqlManagementMode>]
      [-Tag <Hashtable>]
      [-AutoBackupSettingBackupScheduleType <BackupScheduleType>]
      [-AutoBackupSettingBackupSystemDb]
      [-AutoBackupSettingDaysOfWeek <AutoBackupDaysOfWeek[]>]
      [-AutoBackupSettingEnable]
      [-AutoBackupSettingEnableEncryption]
      [-AutoBackupSettingFullBackupFrequency <FullBackupFrequencyType>]
      [-AutoBackupSettingFullBackupStartTime <Int32>]
      [-AutoBackupSettingFullBackupWindowHour <Int32>]
      [-AutoBackupSettingLogBackupFrequency <Int32>]
      [-AutoBackupSettingPassword <SecureString>]
      [-AutoBackupSettingRetentionPeriod <Int32>]
      [-AutoBackupSettingStorageAccessKey <String>]
      [-AutoBackupSettingStorageAccountUrl <String>]
      [-AutoBackupSettingStorageContainerName <String>]
      [-AutoPatchingSettingDayOfWeek <DayOfWeek>]
      [-AutoPatchingSettingEnable]
      [-AutoPatchingSettingMaintenanceWindowDuration <Int32>]
      [-AutoPatchingSettingMaintenanceWindowStartingHour <Int32>]
      [-AssessmentSettingEnable]
      [-AssessmentSettingRunImmediately]
      [-ScheduleDayOfWeek <AssessmentDayOfWeek>]
      [-ScheduleEnable]
      [-ScheduleMonthlyOccurrence <Int32>]
      [-ScheduleStartTime <String>]
      [-ScheduleWeeklyInterval <Int32>]
      [-SqlVirtualMachineGroupResourceId <String>]
      [-VirtualMachineResourceId <String>]
      [-WsfcDomainCredentialsClusterBootstrapAccountPassword <SecureString>]
      [-WsfcDomainCredentialsClusterOperatorAccountPassword <SecureString>]
      [-WsfcDomainCredentialsSqlServiceAccountPassword <SecureString>]
      [-WsfcStaticIP <String>]
      [-EnableAutomaticUpgrade]
      [-ManagedIdentityClientId <String>]
      [-IdentityType <String>]
      [-DefaultProfile <PSObject>]
      [-AsJob]
      [-NoWait]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

Updates a SQL virtual machine.

Examples

Example 1

Update-AzSqlVM -ResourceGroupName 'ResourceGroup01' -Name 'sqlvm1' -LicenseType 'AHUB' -Tag @{'newkey'='newvalue'}

Location	Name		ResourceGroupName
--------	----		-----------------
eastus		sqlvm1		ResourceGroup01

Update a SQL virtual machine with AHUB billing and add a tag.

Example 2

$sqlVM = Get-AzSqlVM -ResourceGroupName 'ResourceGroup01' -Name 'sqlvm1'
$sqlVM | Update-AzSqlVM -Sku 'Standard' -LicenseType 'AHUB'

Location	Name		ResourceGroupName
--------	----		-----------------
eastus		sqlvm1		ResourceGroup01

Update a SQL virtual machine's sku and license type via identity.

Example 3

Update-AzSqlVM -ResourceGroupName 'ResourceGroup01' -Name 'sqlvm1' -AutoBackupSettingEnable `
-AutoBackupSettingBackupScheduleType manual -AutoBackupSettingFullBackupFrequency Weekly -AutoBackupSettingFullBackupStartTime 5 `
-AutoBackupSettingFullBackupWindowHour 2 -AutoBackupSettingStorageAccessKey 'keyvalue' -AutoBackupSettingStorageAccountUrl `
'https://storagename.blob.core.windows.net/' -AutoBackupSettingRetentionPeriod 10 -AutoBackupSettingLogBackupFrequency 60 `
-AutoBackupSettingStorageContainerName 'storagecontainername'

Location	Name		ResourceGroupName
--------	----		-----------------
eastus		sqlvm1		ResourceGroup01

Update a SQL virtual machine to enable auto backup.

Example 4

Update-AzSqlVM -ResourceGroupName 'ResourceGroup01' -Name 'sqlvm1' -AutoBackupSettingEnable:$false

Location	Name		ResourceGroupName
--------	----		-----------------
eastus		sqlvm1		ResourceGroup01

Update a SQL virtual machine to disable auto backup.

Example 5

Update-AzSqlVM -ResourceGroupName 'ResourceGroup01' -Name 'sqlvm1' `
-AutoPatchingSettingDayOfWeek Thursday `
-AutoPatchingSettingMaintenanceWindowDuration 120 -AutoPatchingSettingMaintenanceWindowStartingHour 3 -AutoPatchingSettingEnable

Location	Name		ResourceGroupName
--------	----		-----------------
eastus		sqlvm1		ResourceGroup01

Update a SQL virtual machine to enable auto patching.

Example 6

Update-AzSqlVM -ResourceGroupName 'ResourceGroup01' -Name 'sqlvm1' -AutoPatchingSettingEnable:$false

Location	Name		ResourceGroupName
--------	----		-----------------
eastus		sqlvm1		ResourceGroup01

Update a SQL virtual machine to disable auto patching.

Example 7

Update-AzSqlVM -ResourceGroupName 'ResourceGroup01' -Name 'sqlvm1' -AssessmentSettingEnable

Location	Name		ResourceGroupName
--------	----		-----------------
eastus		sqlvm1		ResourceGroup01

Update a SQL virtual machine to enable assessment.

Example 8

$securepwd = ConvertTo-SecureString -String "****" -AsPlainText -Force
Update-AzSqlVM -ResourceGroupName 'ResourceGroup01' -Name 'sqlvm1' `
-SqlVirtualMachineGroupResourceId '<group resource id>' `
-WsfcDomainCredentialsClusterBootstrapAccountPassword $securepwd `
-WsfcDomainCredentialsClusterOperatorAccountPassword $securepwd `
-WsfcDomainCredentialsSqlServiceAccountPassword $securepwd

Location	Name		ResourceGroupName
--------	----		-----------------
eastus		sqlvm1		ResourceGroup01

Update a SQL virtual machine to add it to a SQL VM group.

Example 9

Update-AzSqlVM -ResourceGroupName 'ResourceGroup01' -Name 'sqlvm1' -SqlVirtualMachineGroupResourceId ''

Location	Name		ResourceGroupName
--------	----		-----------------
eastus		sqlvm1		ResourceGroup01

Update a SQL virtual machine to remove it from a SQL VM group.

Example 10

Update-AzSqlVM -ResourceGroupName 'ResourceGroup01' -Name 'sqlvm1'  -Tag @{'newkey'='newvalue'} -AsJob

Location	Name		ResourceGroupName
--------	----		-----------------
eastus		sqlvm1		ResourceGroup01

Update a SQL virtual machine's tag as a background job.

Example 11

Update-AzSqlVM -ResourceGroupName 'ResourceGroup01' -Name 'sqlvm1' -IdentityType 'SystemAssigned'

Location	Name		ResourceGroupName
--------	----		-----------------
eastus		sqlvm1		ResourceGroup01

Update a SQL virtual machine to enable Microsoft Entra authentication using "System-assigned managed identity"

Example 12

Update-AzSqlVM -ResourceGroupName 'ResourceGroup01' -Name 'sqlvm1' -IdentityType 'UserAssigned' -ManagedIdentityClientId '00001111-aaaa-2222-bbbb-3333cccc4444'

Location	Name		ResourceGroupName
--------	----		-----------------
eastus		sqlvm1		ResourceGroup01

Update a SQL virtual machine to enable Microsoft Entra authentication using "User-assigned managed identity"

Parameters

-AsJob

Run the command as a job

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AssessmentSettingEnable

Enable or disable SQL best practices Assessment feature on SQL virtual machine.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AssessmentSettingRunImmediately

Run SQL best practices Assessment immediately on SQL virtual machine.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoBackupSettingBackupScheduleType

Backup schedule type.

Type:BackupScheduleType
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoBackupSettingBackupSystemDb

Include or exclude system databases from auto backup.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoBackupSettingDaysOfWeek

Days of the week for the backups when FullBackupFrequency is set to Weekly.

Type:AutoBackupDaysOfWeek[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoBackupSettingEnable

Enable or disable autobackup on SQL virtual machine.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoBackupSettingEnableEncryption

Enable or disable encryption for backup on SQL virtual machine.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoBackupSettingFullBackupFrequency

Frequency of full backups. In both cases, full backups begin during the next scheduled time window.

Type:FullBackupFrequencyType
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoBackupSettingFullBackupStartTime

Start time of a given day during which full backups can take place. 0-23 hours.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoBackupSettingFullBackupWindowHour

Duration of the time window of a given day during which full backups can take place. 1-23 hours.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoBackupSettingLogBackupFrequency

Frequency of log backups. 5-60 minutes.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoBackupSettingPassword

Password for encryption on backup.

Type:SecureString
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoBackupSettingRetentionPeriod

Retention period of backup: 1-90 days.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoBackupSettingStorageAccessKey

Storage account key where backup will be taken to.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoBackupSettingStorageAccountUrl

Storage account url where backup will be taken to.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoBackupSettingStorageContainerName

Storage container name where backup will be taken to.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoPatchingSettingDayOfWeek

Day of week to apply the patch on.

Type:DayOfWeek
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoPatchingSettingEnable

Enable or disable autopatching on SQL virtual machine.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoPatchingSettingMaintenanceWindowDuration

Duration of patching.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AutoPatchingSettingMaintenanceWindowStartingHour

Hour of the day when patching is initiated. Local VM time.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:PSObject
Aliases:AzureRMContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-EnableAutomaticUpgrade

Enable automatic upgrade of Sql IaaS extension Agent.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-IdentityType

Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InputObject

Identity Parameter To construct, see NOTES section for INPUTOBJECT properties and create a hash table.

Type:ISqlVirtualMachineIdentity
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-LicenseType

SQL Server license type.

Type:SqlServerLicenseType
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ManagedIdentityClientId

The client Id of the Managed Identity to query Microsoft Graph API. An empty string must be used for the system assigned Managed Identity

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Name

Name of the SQL virtual machine.

Type:String
Aliases:SqlVirtualMachineName, SqlVMName
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-NoWait

Run the command asynchronously

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Offer

SQL image offer. Examples include SQL2016-WS2016, SQL2017-WS2016.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

Name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ScheduleDayOfWeek

Day of the week to run assessment.

Type:AssessmentDayOfWeek
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ScheduleEnable

Enable or disable assessment schedule on SQL virtual machine.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ScheduleMonthlyOccurrence

Occurrence of the DayOfWeek day within a month to schedule assessment. Takes values: 1,2,3,4 and -1. Use -1 for last DayOfWeek day of the month

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ScheduleStartTime

Time of the day in HH:mm format. Eg. 17:30

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ScheduleWeeklyInterval

Number of weeks to schedule between 2 assessment runs. Takes value from 1-6

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Sku

SQL Server edition type.

Type:SqlImageSku
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SqlManagementType

SQL Server Management type.

Type:SqlManagementMode
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SqlVirtualMachineGroupResourceId

ARM resource id of the SQL virtual machine group this SQL virtual machine is or will be part of.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SubscriptionId

Subscription ID that identifies an Azure subscription.

Type:String
Position:Named
Default value:(Get-AzContext).Subscription.Id
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Tag

Resource tags.

Type:Hashtable
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-VirtualMachineResourceId

ARM Resource id of underlying virtual machine created from SQL marketplace image.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WsfcDomainCredentialsClusterBootstrapAccountPassword

Cluster bootstrap account password.

Type:SecureString
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WsfcDomainCredentialsClusterOperatorAccountPassword

Cluster operator account password.

Type:SecureString
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WsfcDomainCredentialsSqlServiceAccountPassword

SQL service account password.

Type:SecureString
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WsfcStaticIP

Domain credentials for setting up Windows Server Failover Cluster for SQL availability group.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

ISqlVirtualMachineIdentity

Outputs

ISqlVirtualMachine