SQL部署任务仅在激活Azure Active Directory身份验证时失败

tyg4sfes  于 2023-08-07  发布在  其他
关注(0)|答案(1)|浏览(144)

你好,我有一个SQL服务器正在部署和管道使用SqlAzureDacpacDeployment@1部署数据库。
作为安全建议的一部分,我们需要在SQL Server设置下的Azure Active Directory菜单中为此服务器启用仅支持Azure Active Directory身份验证。
如果启用此选项,则部署将失败,因为管道任务使用SqlUserName和SqlPassword。我该如何解决这个问题?我应该创建一个新的通用登录是一个AAD用户或有任何其他更好的选择?
如果需要任何其他信息,请随时告诉我。
主yaml

//parameters:

//trigger:
  
//variables: 
 
stages:
- stage: 
  jobs:
  - job: 
    workspace:
      clean: 
    pool:
      
    steps:
    
    - //tasks  
    
- template: templates\myTemplate.yaml
  parameters:
    //list of params

字符串
myTemplate

parameters:

stages:
- stage: 
  variables:
  
  pool:
    name: 
  jobs:
  - deployment: Deploy Azure Infra
    displayName: Deploy Azure Infra
    pool:
      name: 
    environment: 
      name: 
    strategy:
      runOnce:
        deploy:
          steps:
            - download: current
              artifact: drop              
                           
  //job      

  - job: Deploy Database
    dependsOn: 
    displayName: 
    steps:
      - download: current
        artifact: databases

      - task: AzureCLI@2
        displayName: 'Disable'
        inputs:
          azureSubscription: ''
          scriptType: ps
          scriptLocation: inlineScript
          inlineScript: 'az sql server ad-only-auth disable --resource-group rg1 --name mySql'

      - task: SqlAzureDacpacDeployment@1
        displayName: 
        inputs:          

      - task: AzureCLI@2
        displayName: 'Enable'
        inputs:
          azureSubscription: ''
          scriptType: ps
          scriptLocation: inlineScript
          inlineScript: 'az sql server ad-only-auth enable --resource-group rg1 --name mySql'

brc7rcf0

brc7rcf01#

是的,创建通用Azure AD用户并将其添加为Azure SQL Server的管理员将有助于您使用Azure部署dacpacSqlAzureDacpacDeployment任务:-

我添加了一个Azure AD用户作为Azure SQL Server的管理员,如下所示:-

x1c 0d1x的数据

我的Azure yaml管道:-

trigger:
- master

pool:
  vmImage: windows-latest

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

- script: |
    echo Add other tasks to build, test, and deploy your project.
    echo See https://aka.ms/yaml
  displayName: 'Run a multi-line script'

- task: AzureCLI@2
  inputs:
    azureSubscription: 'devopsappsilicon'
    scriptType: 'bash'
    scriptLocation: 'inlineScript'
    inlineScript: 'az sql server ad-only-auth disable --resource-group pratikrg1 --name siliconserver'
- task: SqlAzureDacpacDeployment@1
  inputs:
    azureSubscription: 'devopsappsilicon'
    AuthenticationType: 'aadAuthenticationPassword'
    ServerName: 'siliconserver.database.windows.net'
    DatabaseName: 'silicondb'
    aadSqlUsername: 'test4@outlook.onmicrosoft.com'
    aadSqlPassword: 'Password'
    deployType: 'DacpacTask'
    DeploymentAction: 'Publish'
    DacpacFile: '$(System.DefaultWorkingDirectory)/Database1.dacpac'
    IpDetectionMethod: 'IPAddressRange'
    StartIpAddress: '0.0.0.0'
    EndIpAddress: '255.255.255.255'
    
- task: AzureCLI@2
  inputs:
        azureSubscription: 'devopsappsilicon'
        scriptType: 'bash'
        scriptLocation: 'inlineScript'
        inlineScript: 'az sql server ad-only-auth enable --resource-group pratikrg1 --name siliconserver'

字符串

输出:-



相关问题