AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[azure-arm-template](server)

Martin Hope
justin.m.chase
Asked: 2021-09-18 12:53:39 +0800 CST

通过 ARM/Bicep 模板将网络参与者角色分配给 AKS 群集的正确方法是什么?

  • 0

我正在尝试使用 Bicep/ARM 为我的 AKS 服务器配置负载均衡器。我在 kubernetes 中使用 NGinx 入口控制器,它似乎确实可以工作,但是当我第一次启动时,我遇到了一个错误。

主要是我想知道 Azure 文档中此步骤的等效 ARM 或 Bicep 模板是什么?

https://docs.microsoft.com/en-us/azure/aks/static-ip#create-a-service-using-the-static-ip-address

az role assignment create \
    --assignee <Client ID> \
    --role "Network Contributor" \
    --scope /subscriptions/<subscription id>/resourceGroups/<resource group name>

我正在使用 Bicep 并创建了我的 AKS 服务器,例如:

resource ExampleKubernetes 'Microsoft.ContainerService/managedClusters@2021-07-01' = {
  // ...
}

然后我向 kubelet 身份添加角色分配,如下所示:

var NetworkContibutor = '4d97b98b-1d4f-4787-a291-c67834d212e7'
resource AssignNetworkContributorToKubelet 'Microsoft.Authorization/roleAssignments@2020-08-01-preview' = {
  name: guid(resourceGroup().id, ExampleKubernetes.id, NetworkContibutor)
  dependsOn: [
    ExampleKubernetes
  ]
  properties: {
    roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', NetworkContibutor)
    principalType: 'ServicePrincipal'
    principalId: ExampleKubernetes.properties.identityProfile.kubeletidentity.objectId
  }
}

这似乎可行,我可以在仪表板中看到分配给托管主体的角色......但是 kubernetes 中的服务似乎仍然失败,并且仍然存在权限问题:

  Error syncing load balancer: failed to ensure load balancer: Retriable: false,
  RetryAfter: 0s, HTTPStatusCode: 403, RawError: Retriable: false, RetryAfter:
  0s, HTTPStatusCode: 403, RawError:
  {"error":{"code":"AuthorizationFailed","message":"The client
  '<some guid A>' with object id
  '<some buid A>' does not have authorization to perform
  action 'Microsoft.Network/publicIPAddresses/read' over scope
  '/subscriptions/<subid>/resourceGroups/example/providers/Microsoft.Network/publicIPAddresses/example'
  or the scope is invalid. If access was recently granted, please refresh your
  credentials."}}

奇怪的是,后来在某些时候它似乎只是神奇地工作。该错误显示“retriable false”,并且该服务似乎没有重试,但随后将 NGinx 部署到 kubernetes 将导致它重试并突然繁荣其工作。

似乎错误消息告诉我角色传播存在一些不确定的延迟......所以我的问题是:

  • 那正确吗?实际上只是延迟并且我的代码基本上是正确的吗?
  • 我使用了正确的 principalId 吗?或者这实际上是不必要的?
  • 有没有办法让我强制传播这些角色更新?如果需要,我可以在两者之间有一个 CLI 步骤。权限准备好后,如何等待安装连接到 LB 的入口控制器?
kubernetes azure aks azure-arm-template azure-networking
  • 1 个回答
  • 989 Views
Martin Hope
Kolky
Asked: 2021-02-26 09:16:33 +0800 CST

Azure Deploy 失败后,我们部署的 AppService 为空

  • 1

我们有一个 Azure DevOps 管道,它首先使用 ARM 模板部署我们的资源,然后使用 zip 部署我们的 AppServices。我们已经多次运行管道,并且应用程序正在正确运行。

在另一次部署尝试之后的某个时间 - (资源的)第一个部署步骤失败。部署中的更改不包含对 AppService 的任何更改。并且失败的部分不是AppService(而是说我们的数据库),AppService 仍然不可用。看起来它已重置为默认托管设置。似乎以前的部署在“/data/SitePackages”文件夹中仍然可用,但“/site/wwwroot”文件夹仅包含默认的“hostingstart.html”文件。

我对增量部署的理解是,如果 AppService 未更改,它应该保留所有设置!(因此它之前的部署处于活动状态。)

这是默认行为吗?当部分部署失败时,我们能否以某种方式保持以前的应用程序运行?我们是否需要选择另一种部署策略?

我们的管道看起来像这样;

jobs:
  - deployment: 'Deploy'
    environment: '${{ parameters.environment }}' # The environment to use in Azure Devops (controls the required approvals)
    variables:
      - template: '../variables/deploy-variables.yml'
        parameters:
          environment: '${{ parameters.environment }}'
    strategy:
      runOnce:
        deploy:
          steps:
          - task: AzureResourceManagerTemplateDeployment@3
            displayName: 'Azure - Deploy resources'
            inputs:
              deploymentScope: 'Resource Group'
              azureResourceManagerConnection: '${{ parameters.azureServiceConnection }}'
              subscriptionId: '$(azureSubscriptionId)'
              action: 'Create Or Update Resource Group'
              resourceGroupName: '$(resourceGroup)'
              location: 'West Europe'
              templateLocation: 'Linked artifact'
              csmFile: '$(Pipeline.Workspace)/drop-resources/files/arm/resources/azuredeploy.json'
              csmParametersFile: '$(Pipeline.Workspace)/drop-resources/files/arm/resources/azuredeploy.parameters.json'
              deploymentMode: 'Incremental'

          - task: AzureWebApp@1
            displayName: 'Deploy Service'
            inputs:
              azureSubscription: '${{ parameters.azureServiceConnection }}'
              appName: '$(serviceName)'
              package: '$(Pipeline.Workspace)/drop-app/archives/Service.zip'
azure azure-arm-template azure-app-services
  • 2 个回答
  • 447 Views
Martin Hope
jrd1989
Asked: 2020-11-25 13:01:43 +0800 CST

ARM 模板 - Azure SQL 数据库诊断和日志分析工作区

  • 1

使用ARM 模板,我想为我的Azure SQL 数据库启用诊断设置,并将该数据存储在我创建的Log Analytics 工作区中。我想启用错误、超时、阻塞和等待统计日志以及基本指标选项。我能够使用 Web 应用程序来实现此功能,因此我采用了类似的方法,但我的模板失败并抛出错误,指出我引用的指标或诊断类别不存在或不受支持。这是我的模板的一些资源部分:

我不确定是否需要在模板中启用或引用其他设置才能使其正常工作,但我将不胜感激,谢谢!

          "resources": [
                {
                    "type": "databases",
                    "apiVersion": "2019-06-01-preview",
                    "name": "[parameters('sqlDatabase')]",
                    "location": "[parameters('location')]",
                    "tags": {},
                    "dependsOn": [
                        "[parameters('sqlServer')]"
                    ],
                    "sku": {
                        "name": "GP_Gen5_4",
                        "tier": "GeneralPurpose"
                    },
                    "properties": {
                        "startIpAddress": "0.0.0.0",
                        "endIpAddress": "0.0.0.0"
                    }
                },

                {
                    "type": "providers/diagnosticSettings",
                    "name": "[concat('Microsoft.Insights/', parameters('diagnostics-name'))]",
                    "dependsOn": [
                        "[resourceId('Microsoft.Sql/servers', parameters('sqlServer'))]",
                        "[resourceId('Microsoft.Sql/servers/databases', parameters('sqlServer'), parameters('sqlDatabase'))]"
                    ],

                    "apiVersion": "2017-05-01-preview",
                    "properties": {
                        "name": "[parameters('diagnostics-name')]",
                        "workspaceId": "[concat('subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('loganalytics-rg'), '/providers/Microsoft.OperationalInsights/workspaces/', parameters('workspacename'))]",
                        "logs": [
                            {
                                "category": "Errors",
                                "enabled": "true",
                                "retentionPolicy": {
                                    "enabled": "true",
                                    "days": 7
                                }
                            },
                            {
                                "category": "DatabaseWaitStatistics",
                                "enabled": "true",
                                "retentionPolicy": {
                                    "enabled": "true",
                                    "days": 7
                                }
                            },
                            {
                                "category": "Timeouts",
                                "enabled": "true",
                                "retentionPolicy": {
                                    "enabled": "true",
                                    "days": 7
                                }
                            },
                            {
                                "category": "Blocks",
                                "enabled": "true",
                                "retentionPolicy": {
                                    "enabled": "true",
                                    "days": 7
                                }
                            }

                        ]
                    }
                }
            ]
        }
    ]
}
database diagnostic azure-arm-template log-analytics-workspace azure-sql
  • 1 个回答
  • 872 Views
Martin Hope
jrd1989
Asked: 2020-11-19 11:14:05 +0800 CST

构建管道 ARM 模板 - TFS 2018

  • 0

我的客户使用TFS 2018 作为他们的 CI/CD 工具。我知道您可以使用 TFS 将ARM 模板部署到Azure,但我以前从未这样做过。我通常只使用门户或 powershell。我知道我需要创建一个管道来执行部署,但我还有一些其他问题让我感到困惑:

  1. 如果基础设施没有改变(或几乎没有改变), ARM 模板是否需要构建和发布 管道(两者)?我的印象是大多数人使用构建管道来验证模板或他们的代码,然后发布是部署到天蓝色或任何地方。
  2. 我可以使用一个包含我所有资源的单个 ARM 模板进行部署,还是必须部署单个模板(ASP,然后是 Web 应用程序,然后是存储帐户,然后是 Redis)?
  3. 在我部署任何东西之前需要一个资源组。我是否可以在 ARM 模板中包含其他所有内容(RG + 一个模板中的所有资源)中的资源组创建步骤,或者我需要一个 RG 模板,然后是其他模板?
  4. 如果它们是多个环境(开发、测试、产品),我是否需要为每个环境提供多个构建/发布管道,或者是否可以配置指向每个环境的管道?每个环境中的资源都会有不同的命名约定,所以除了必须更新 ARM 模板中的值之外,我不确定这会如何影响其他事情。

对于上述问题,我将不胜感激任何建议/建议,谢谢!

team-foundation-server deployment azure azure-arm-template continuous-integration
  • 2 个回答
  • 91 Views
Martin Hope
Omar Obeid
Asked: 2020-06-03 05:34:15 +0800 CST

如何更改 ARM 模板中的 RDP 端口号?

  • 0

在 Azure 上创建 VM 后,我需要使用 VPN 才能对其进行 RDP。这是因为我的 Internet 服务提供商的网络规定。因此,每次创建新 VM 时,我都必须从 VM 中更改 RPD 端口。有没有办法可以使用 Azure 模板设置默认 RDP 端口号(例如:8000)?

rdp azure azure-arm-template azure-networking
  • 1 个回答
  • 52 Views
Martin Hope
Danslerr
Asked: 2020-05-06 06:54:35 +0800 CST

在现有 vnet 中创建新 VM、子网和 NSG 时出错

  • 0

我正在尝试使用新 NSG 在新子网中部署新虚拟机,但在部署模板时出现错误。

我们是一家 MSP,为我们的客户构建名为“SoftWare”的自定义软件,我们希望将其托管在 Azure 中。

我目前的设置如下*:

  • 名为 Contoso.Cloud 的资源组
  • 一个虚拟网络也名为 Contoso.Cloud,地址空间为 10.2.0.0/16
  • 一个子网,它托管我们的后端服务,如 Active Directory 等,前缀为 10.2.10.0/24。
  • 所有资源都部署在同一个资源组中

我使用此模板的目标是在每次创建新客户端 VM 时在 Contoso.Cloud vnet 中部署新子网和 NSG。

*出于安全原因,对姓名进行了消毒

这是我的模板:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "adminUsername": {
            "type": "String",
            "metadata": {
                "description": "Username for the Virtual Machine."
            }
        },
        "adminPassword": {
            "type": "SecureString",
            "metadata": {
                "description": "Password for the Virtual Machine."
            }
        },
        "vmSize": {
            "defaultValue": "Standard_F2s_v2",
            "allowedValues": [
                "Standard_F2s_v2",
                "Standard_F4s_v2"
            ],
            "type": "String",
            "metadata": {
                "description": "Size of the virtual machine."
            }
        },
        "clientCode": {
            "type": "String",
            "metadata": {
                "description": "Please enter the ID of the clinic."
            }
        },
        "clientName": {
            "type": "String",
            "metadata": {
                "description": "Please enter the code of the clinic."
            }
        },
        "addressPrefix": {
            "defaultValue": "10.2.0.0/16",
            "allowedValues": [
                "10.2.0.0/16"
            ],
            "type": "String",
            "metadata": {
                "description": "Please enter the vnet address prefix here."
            }
        },
        "subnetPrefix": {
            "type": "String",
            "metadata": {
                "description": "Please enter the subnet prefix here."
            }
        }
    },
    "variables": {
        "storageAccountName": "ContosoStorageTST",
        "nicName": "[concat(toLower(variables('vmName')), '-', uniqueString(resourceGroup().id))]",
        "addressPrefix": "[parameters('addressPrefix')]",
        "subnetName": "[concat(parameters('clientCode'), '_', parameters('clientName'))]",
        "subnetPrefix": "[parameters('subnetPrefix')]",
        "vmName": "[concat(parameters('clientCode'), '-SoftWare1')]",
        "virtualNetworkName": "Contoso.Cloud",
        "subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]",
        "networkSecurityGroupName": "[concat('SoftWare-NSG-', parameters('clientCode'))]",
        "backendSubnet": "10.2.10.0/24",
        "location": "West Europe"
    },
    "resources": [
        {
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2018-11-01",
            "name": "[variables('storageAccountName')]",
            "location": "[variables('location')]",
            "sku": {
                "name": "Standard_LRS"
            },
            "kind": "Storage",
            "properties": {}
        },
        {
            "type": "Microsoft.Network/networkSecurityGroups",
            "apiVersion": "2019-08-01",
            "name": "[variables('networkSecurityGroupName')]",
            "location": "[variables('location')]",
            "properties": {
                "securityRules": [
                    {
                        "name": "allow_RDP_in",
                        "properties": {
                            "protocol": "tcp",
                            "sourcePortRange": "*",
                            "destinationPortRange": "3389",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "[parameters('subnetPrefix')]",
                            "access": "Allow",
                            "priority": 500,
                            "direction": "Inbound"
                        }
                    },
                    {
                        "name": "allow_core_to_client",
                        "properties": {
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "22",
                            "sourceAddressPrefix": "[variables('backendSubnet')]",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 501,
                            "direction": "Inbound"
                        }
                    },
                    {
                        "name": "allow_client_to_core",
                        "properties": {
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "*",
                            "sourceAddressPrefix": "[parameters('subnetPrefix')]",
                            "destinationAddressPrefix": "[variables('backendSubnet')]",
                            "access": "Allow",
                            "priority": 502,
                            "direction": "Outbound"
                        }
                    },
                    {
                        "name": "deny_client_to_other_clients",
                        "properties": {
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "*",
                            "sourceAddressPrefix": "[variables('addressPrefix')]",
                            "destinationAddressPrefix": "[variables('addressPrefix')]",
                            "access": "Deny",
                            "priority": 4000,
                            "direction": "Outbound"
                        }
                    }
                ]
            }
        },
        {
            "type": "Microsoft.Network/virtualNetworks/subnets",
            "apiVersion": "2018-04-01",
            "name": "[concat(variables('virtualNetworkName'), '/', variables('subnetName'))]",
            "location": "[variables('location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Network/networkSecurityGroups/', variables('networkSecurityGroupName'))]"
            ],
            "properties": {
                "addressPrefix": "[variables('subnetPrefix')]",
                "networkSecurityGroup": "[variables('networkSecurityGroupName')]"
            }
        },
        {
            "type": "Microsoft.Network/networkInterfaces",
            "apiVersion": "2018-11-01",
            "name": "[variables('nicName')]",
            "location": "[variables('location')]",
            "dependsOn": [
                "[concat('/subscriptions/<subscription-ID>/resourceGroups/SoftWare.Cloud/providers/Microsoft.Network/virtualNetworks/SoftWare.Cloud/subnets/', variables('subnetName'))]"

            ],
            "properties": {
                "ipConfigurations": [
                    {
                        "name": "ipconfig1",
                        "properties": {
                            "privateIPAllocationMethod": "Dynamic",
                            "subnet": {
                                "id": "[variables('subnetRef')]"
                            }
                        }
                    }
                ]
            }
        },
        {
            "type": "Microsoft.Compute/virtualMachines",
            "apiVersion": "2018-10-01",
            "name": "[variables('vmName')]",
            "location": "[variables('location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
                "[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]",
                "[concat('/subscriptions/<subscription-ID>/resourceGroups/SoftWare.Cloud/providers/Microsoft.Network/virtualNetworks/SoftWare.Cloud/subnets/', variables('subnetName'))]"
            ],
            "properties": {
                "hardwareProfile": {
                    "vmSize": "[parameters('vmSize')]"
                },
                "osProfile": {
                    "computerName": "[variables('vmName')]",
                    "adminUsername": "[parameters('adminUsername')]",
                    "adminPassword": "[parameters('adminPassword')]"
                },
                "storageProfile": {
                    "imageReference": {
                        "id": "[resourceId('Microsoft.Compute/images', 'SoftWare1-IMAGE-Roles ')]"
                    },
                    "osDisk": {
                        "createOption": "FromImage"
                    }
                },
                "networkProfile": {
                    "networkInterfaces": [
                        {
                            "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
                        }
                    ]
                },
                "diagnosticsProfile": {
                    "bootDiagnostics": {
                        "enabled": false,
                        "storageUri": "[reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))).primaryEndpoints.blob]"
                    }
                }
            }
        }
    ]
}

这些是我的参数:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "adminUsername": {
      "value": "admin-local"
    },
    "adminPassword": {
      "value": "myPassword,"
    },
    "vmSize": {
      "value": "Standard_F2s_v2"
    },
    "clientCode": {
      "value": "TST01"
    },
    "clientName": {
      "value": "TST-Example"
    },
    "addressPrefix": {
      "value": "10.2.0.0/16"
    },
    "subnetPrefix": {
      "value": "10.2.20.0/28"
    }
  }
}

我得到的错误是:

 "Cannot parse the request. (Code: InvalidRequestFormat)
    - Value for reference id is missing. Path properties.networkSecurityGroup. (Code: MissingJasonReferenceId)

这使我相信我需要在部署子网时对 NSG 进行额外的引用,但在每个示例模板中我发现这不会发生。当我使用不同的模板仅部署子网而不使用 NSG 时,它会顺利进行。

另一个问题可能是在网络接口上没有指定 vnet,但是当我查看示例时,他们唯一做的就是使用“dependsOn”选项,该选项仅在 vnet 与网络接口。然而,情况并非如此。

azure azure-arm-template
  • 1 个回答
  • 313 Views
Martin Hope
Alan Mullett
Asked: 2020-03-01 09:14:53 +0800 CST

Azure 模板:使用参数值按名称访问变量的成员

  • 0

我在模板中有一个变量,其中包含许多条目,这些条目将在我的模板中指定值。我的意思是我有

    "ipSecurityRestrictions" : {
      "denyAllInbound": 
      [
        {
          "ipAddress": "0.0.0.0/0",
          "action": "Deny",
          "priority": 100,
          "name": "Deny All Inbound"
        }
      ],
      "allowAppGatewayOnly": 
      [
        {
          "vnetSubnetResourceId": "[variables('appGatewaySubnet')]",
          "action": "allow",
          "priority": 100,
          "name": "Allow App Gateway"
        }
      ]
    }
  }

我目前使用一个简单的 if 函数来根据参数确定要使用的函数(它实际上比这要复杂一些,但这对于这个问题来说已经足够了。)所以目前我有类似的东西

[if (equals(parameters('a'), 'allowAppGatewayOnly'), variables('ipSecurityRestrictions').allowAppGatewayOnly, variables('ipSecurityRestrictions').denyAllInbound)]

这很高兴地工作。但是,我想在变量中添加另一个条目,我不喜欢在其中有一个 if 链的想法,它很快就会变得丑陋。

所以我尝试了各种基于参数值的间接使用方法(所有这些都在复制循环内,参数数组中的不同条目可能有不同的条目)。

我尝试过类似的事情

"[variables('ipSecurityRestrictions')[parameters('appservices')[copyIndex()].ipSecurityRestrictions]]"

但我要问的事实意味着它没有用。[编辑:它确实有效 - 如果参数值是正确的,并且其中没有杂散的单引号!]

是否可以在 ARM 模板中执行此操作,或者如果函数调用,我是否坚持使用嵌套?

谢谢

azure azure-arm-template
  • 1 个回答
  • 143 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve