Gag*_*ngh 7 azure-devops azure-pipelines
有没有办法运行正在运行的主机的IP地址范围?
这与发布管道->托管代理有关。
问题:由于防火墙拒绝连接,连接被拒绝访问。需要将此请求的IP地址范围列入白名单,这些请求来自DevOps上的发布管道。
小智 9
我在发行版中迈出了一步,可以通过以下方式在Powershell中获取托管代理IP地址:
Invoke-RestMethod http://ipinfo.io/json | Select -exp ip
Run Code Online (Sandbox Code Playgroud)
希望能有所帮助。
小智 9
对于 Windows 构建代理,使用 powershell 路由更安全:
steps:
- task: AzurePowerShell@5
displayName: 'Add buildserver public ip'
inputs:
azureSubscription: test
ScriptType: InlineScript
Inline: |
$ip = (Invoke-WebRequest -uri "http://ifconfig.me/ip").Content
New-AzSqlServerFirewallRule -ResourceGroupName "group" -ServerName "database-server-name" -FirewallRuleName "azuredevops" -StartIpAddress $ip -EndIpAddress $ip
azurePowerShellVersion: LatestVersion
Run Code Online (Sandbox Code Playgroud)
该池每周都会从 Microsoft 获得更新。因此,不可能对其进行维护。
对于这个问题,我创建了一个新的 Bash 任务。该任务从代理获取当前 IP,并将其列入 AWS 安全组白名单。在完成管道之前,我已经撤销了上述IP。
Current_IP=$(curl ipinfo.io/ip)
echo $Current_IP
# Authorize access
aws ec2 authorize-security-group-ingress \
--group-id sg-xxxxxxxx \
--protocol tcp \
--port 9000 \
--cidr $Current_IP/32
# Revoke access
aws ec2 revoke-security-group-ingress \
--group-id sg-xxxxxxx \
--protocol tcp \
--port 9000 \
--cidr $Current_IP/32
Run Code Online (Sandbox Code Playgroud)
为了使 aws-cli 命令发挥作用,我们还需要一个受限制的 aws 策略,该策略允许以有限的访问权限运行上述命令。
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"ec2:RevokeSecurityGroupIngress",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:ModifySecurityGroupRules"
],
"Resource": "arn:aws:ec2:us-east-2:xxxxxx:security-group/sg-xxxxx"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我们需要将 Azure 数据中心使用的 IP 地址列入白名单,如下所示: https: //www.microsoft.com/en-nz/download/details.aspx ?id=41653
注意:此列表每周都会更新,因此请在部署规划时注意这一点
| 归档时间: |
|
| 查看次数: |
6173 次 |
| 最近记录: |