我正在使用Azure DevOps部署Web应用程序并为SQL数据库执行数据库迁移。我有一个服务连接设置,并且能够使用Azure CLI部署Azure资源,例如
- task: AzureCLI@2
displayName: 'Deploy Azure resources'
inputs:
azureSubscription: 'My Service Connection'
scriptType: 'bash'
scriptLocation: inlineScript
inlineScript: ./deploy.sh
现在,我想执行数据库迁移,并且想使用服务连接进行身份验证(已向应用程序注册授予对SQL数据库的访问权限)。我的理解是我可以使用OAuth令牌登录SQL数据库-我的问题是如何使用服务连接获取该令牌。
请注意,我无法将客户端机密添加到Azure中的服务主体,因此也无法使用/oauth2/token
来对client_secret
进行REST调用(我在企业领域工作,事情就被锁定了。)
鉴于管道可以访问Azure DevOps服务连接,我的感觉是必须有某种方法可以使用它来获取对https://database.windows.net/
资源有效的OAuth令牌-但是如何?
答案 0 :(得分:1)
在以下情况下,您可以尝试解决方案:Azure Pipeline connect to SQL DB using service principal
添加用于检索承载令牌的Azure CLI任务。然后通过 这是使用令牌的Azure Powershell任务。
<form class="login-form" th:action="@{/checkUser}" method="post" th:object="${user}"> <!-- Success Massage for the user after registration --> <div style="text-align: center; font-size: 15px; color: #797979; font-weight: bold"> <span style="color: yellow;" th:utext="${message}"></span> <span style="color: yellow;" th:utext="${messageUserNotExist}"></span> </div> <div class="login-wrap"> <p class="login-img"><i class="icon_lock_alt"></i></p> <div class="input-group"> <span class="input-group-addon"><i class="icon_profile"></i></span> <input type="text" class="form-control" placeholder="Username" id="username" name="username" autofocus> </div> <div class="input-group"> <span class="input-group-addon"><i class="icon_key_alt"></i></span> <input type="password" class="form-control" placeholder="Password" id="password" name="password" autocomplete="off"> </div> <!--<label class="checkbox"> <span class="pull-right"><input type="submit" value="Login" onclick="lsRememberMe()"></span> </label>--> <span class="pull-right"><input type="checkbox" value="lsRememberMe" id="rememberMe"> Remember me </span> <span class="pull-left"><a th:href="@{/forgotPassword}">Forgot Password?</a></span> <span><button class="btn btn-primary btn-lg btn-block" type="submit" value="Login" id="submit" onclick="lsRememberMe()">Login</button></span> <a th:href="@{/registerPage2}" class="btn btn-info btn-lg btn-block">Sign Up</a> <!-- <a th:href="@{/users/checkUser}" class="btn btn-info btn-lg btn-block"> Login</a> --> <!-- <input type="submit" value="Login" onclick="lsRememberMe()"> --> <!-- <button class="btn btn-primary btn-lg btn-block" type="submit" value="Login" onclick="lsRememberMe()">Login</button> --> </div>