Thank you @Allan Solomon Mejia & @Tejaswini Billakurthi
I want to reset the password of SQL server through Azure pipeline. I don't have access to change the password manually in Azure portal/CLI/Powershell.
- Currently, I'm trying to reset the password using Azure pipeline.
- There is already an existing pipeline running.
- So, to reset the password, how can I include my script inside that pipeline yml script.
- Here, I was stuck. Can anyone help me on this?
Azure DevOps
3 answers
Sort by: Newest
-
Tejaswini Billakurthi 760 Reputation points Microsoft External Staff Moderator
2026-09-09T12:07:32.96+00:00 Hello @Chandra Vamsi Tiruveedula ,
Thank you for reaching out to Microsoft Q & A !
The approach described by @Allan Solomon Mejia is correct.
Azure SQL Server administrator password changes can be automated through an Azure DevOps pipeline, but the pipeline must use a service connection that has sufficient permissions on the target SQL Server resource.
If the service connection does not have the required Azure RBAC permissions (for example, permission to modify the SQL Server resource), the password reset operation will fail regardless of whether it is performed through the Azure portal, Azure CLI, PowerShell, or an Azure DevOps pipeline.
Please verify that the Azure Resource Manager service connection used by the pipeline has the necessary permissions on the SQL Server or its resource group.
Please "Upvote the Answer" if this information helped you. This will help us and others in the community as well.
-
Allan Solomon Mejia 10,465 Reputation points2026-08-23T17:20:05.2633333+00:00 Hello @Chandra Vamsi Tiruveedula
Yes, you can reset an Azure SQL logical server administrator password from an Azure DevOps YAML pipeline. However, the pipeline still needs an identity that is authorized to modify that SQL server.
In other words, if you personally don't have permission to reset the password through Portal, CLI, or PowerShell, putting the same operation inside a pipeline doesn't bypass Azure RBAC. The Azure Resource Manager service connection used by the pipeline must have the necessary permission on the SQL server or its resource group.
Microsoft supports changing the administrator password using:
az sql server update \ --resource-group <resource-group> \ --name <sql-server-name> \ --admin-password "<new-password>"The az sql server update command specifically provides the --admin-password parameter for this purpose.
Since you already have an Azure DevOps pipeline, you can execute it using an AzureCLI@2 task:
variables: resourceGroup: 'my-resource-group' sqlServer: 'my-sql-server' steps: - task: AzureCLI@2 displayName: 'Reset Azure SQL administrator password' inputs: azureSubscription: 'My-Azure-Service-Connection' scriptType: 'bash' scriptLocation: 'inlineScript' inlineScript: | az sql server update \ --resource-group "$(resourceGroup)" \ --name "$(sqlServer)" \ --admin-password "$(SqlAdminPassword)"My-Azure-Service-Connection should be an authorized Azure Resource Manager service connection. Microsoft documents AzureCLI@2 specifically for running Azure CLI commands against an Azure subscription through such a connection.
Do not put the password directly in the YAML file. Create SqlAdminPassword as a secret pipeline variable, variable-group secret, or preferably retrieve it from Azure Key Vault if that's part of your environment.
The equivalent PowerShell operation is also supported:
$securePassword = ConvertTo-SecureString "$(SqlAdminPassword)" -AsPlainText -Force Set-AzSqlServer ` -ResourceGroupName "$(resourceGroup)" ` -ServerName "$(sqlServer)" ` -SqlAdministratorPassword $securePasswordMicrosoft documents Set-AzSqlServer specifically with an example for resetting the SQL server administrator password.
The main issue in your case, though, is authorization.
If your Azure DevOps service connection doesn't have permission to perform Microsoft.Sql/servers/write on that SQL server, the pipeline will fail even though the YAML is correct. You'll need your Azure administrator/subscription owner to grant the service connection's identity an appropriate role at the narrowest practical scope.
I wouldn't recommend granting your personal account broader Azure access just to make this work. For automation, using a dedicated service connection with only the required permissions is the cleaner approach.
Sharing these references with you:
Microsoft – az sql server update
Microsoft – Azure Resource Manager service connections
If you can share what type of SQL Server this is (Azure SQL Database logical server, SQL Managed Instance, or SQL Server running inside an Azure VM) and what Azure service connection your existing pipeline uses, I can provide the exact YAML for that environment.
Hope this helps. If this resolves your question, please consider "Accepting the Answer" so it can help others in the community.