ARM şablonu kullanarak Cloud Services'i (genişletilmiş destek) dağıtma

Önemli

31 Mart 2025 itibarıyla bulut Hizmetleri (genişletilmiş destek) kullanımdan kaldırılmıştır ve 31 Mart 2027'de tamamen kullanımdan kaldırılacaktır. Bu özelliğin kullanım dışı kalması ve geçiş süreçleri hakkında daha fazla bilgi edinin.

Bu makalede, Azure Cloud Services (genişletilmiş destek) dağıtımı oluşturmak için Azure Resource Manager şablonunun (ARM şablonu) nasıl kullanılacağı gösterilmektedir.

Önkoşullar

ARM şablonlarını kullanarak dağıtımınızı oluşturmanın önkoşulları olarak aşağıdaki adımları tamamlayın.

  1. Cloud Services (genişletilmiş destek) için dağıtım önkoşullarını gözden geçirin ve gerekli kaynakları oluşturun.

  2. Azure portalını veya Azure PowerShell'i kullanarak yeni bir kaynak grubu oluşturun. Mevcut bir kaynak grubunu kullanıyorsanız bu adım isteğe bağlıdır.

  3. Azure portalını veya Azure PowerShell'i kullanarak yeni bir depolama hesabı oluşturun. Mevcut bir depolama hesabı kullanıyorsanız bu adım isteğe bağlıdır.

  4. Azure portalını veya Azure PowerShell'i kullanarak paket (.cspkg veya .zip) dosya ve yapılandırma (.cscfg) dosyasını depolama hesabına yükleyin. Sonraki bir adımda ARM şablonuna eklenecek her iki dosya için paylaşılan erişim imzası (SAS) URI'lerini kaydedin.

  5. (İsteğe bağlı) Bir anahtar kasası oluşturun ve sertifikaları karşıya yükleyin.

    • Dağıtımınıza, hizmetle güvenli iletişim sağlamak için sertifikalar ekleyebilirsiniz. Sertifikaları kullanıyorsanız, sertifika parmak izlerinin yapılandırma (.cscfg) dosyanızda belirtilmesi ve bir anahtar kasasına yüklenmesi gerekir. Azure portalını veya Azure PowerShell'i kullanarak anahtar kasası oluşturabilirsiniz.
    • The associated key vault must be in the same region and subscription as your Cloud Services (extended support) deployment.
    • Cloud Services (genişletilmiş destek) kaynaklarının anahtar kasasından sertifika alabilmesi için ilişkili anahtar kasasının ilgili izinlere sahip olması gerekir. Daha fazla bilgi için bkz. Cloud Services ile sertifikaları kullanma (genişletilmiş destek).
    • The key vault must be referenced in the osProfile section of the ARM template as shown in a later step.

Cloud Services'ı dağıtma (genişletilmiş destek)

Cloud Services'ı (genişletilmiş destek) bir şablon kullanarak dağıtmak için:

Note

ARM şablonunuzu ve parametre dosyanızı oluşturmanın daha kolay ve daha hızlı bir yolu Azure portalını kullanmaktır. Azure PowerShell aracılığıyla Bulut Hizmetlerinizi (genişletilmiş destek) oluşturmak için oluşturulan ARM şablonunu portaldan indirebilirsiniz.

  1. Özel ağ oluşturun. Sanal ağın adı, yapılandırma (.cscfg) dosyasındaki sanal ağ başvuruları ile eşleşmelidir. Mevcut bir sanal ağı kullanıyorsanız ARM şablonundan bu bölümü atla.

    "resources": [ 
        { 
          "apiVersion": "2019-08-01", 
          "type": "Microsoft.Network/virtualNetworks", 
          "name": "[parameters('vnetName')]", 
          "location": "[parameters('location')]", 
          "properties": { 
            "addressSpace": { 
              "addressPrefixes": [ 
                "10.0.0.0/16" 
              ] 
            }, 
            "subnets": [ 
              { 
                "name": "WebTier", 
                "properties": { 
                  "addressPrefix": "10.0.0.0/24" 
                } 
              } 
            ] 
          } 
        } 
    ] 
    

    Yeni bir sanal ağ oluşturursanız, platformun Cloud Services (genişletilmiş destek) örneğini oluşturmadan önce sanal ağı oluşturduğundan emin olmak için bölümüne aşağıdaki satırları dependsOn ekleyin:

    "dependsOn": [ 
            "[concat('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]" 
     ] 
    
  2. Bir genel IP adresi oluşturun ve (isteğe bağlı olarak) genel IP adresinin DNS etiketi özelliğini ayarlayın. Statik IP adresi kullanıyorsanız, yapılandırma (.cscfg) dosyasında onu ayrılmış bir IP adresi olarak tanımlamanız gerekir. Mevcut bir IP adresi kullanıyorsanız, bu adımı atlayın ve IP adresi bilgilerini doğrudan ARM şablonunuzdaki yük dengeleyici yapılandırma ayarlarına ekleyin.

    "resources": [ 
        { 
          "apiVersion": "2019-08-01", 
          "type": "Microsoft.Network/publicIPAddresses", 
          "name": "[parameters('publicIPName')]", 
          "location": "[parameters('location')]", 
          "properties": { 
            "publicIPAllocationMethod": "Dynamic", 
            "idleTimeoutInMinutes": 10, 
            "publicIPAddressVersion": "IPv4", 
            "dnsSettings": { 
              "domainNameLabel": "[variables('dnsName')]" 
            } 
          }, 
          "sku": { 
            "name": "Basic" 
          } 
        } 
    ] 
    

    Yeni bir IP adresi oluşturursanız, platformun Cloud Services (genişletilmiş destek) örneğini oluşturmadan önce IP adresini oluşturduğundan emin olmak için bölümüne aşağıdaki satırları dependsOn ekleyin:

    "dependsOn": [ 
            "[concat('Microsoft.Network/publicIPAddresses/', parameters('publicIPName'))]" 
          ] 
    
  3. Bir Cloud Services (genişletilmiş destek) nesnesi oluşturun. Add relevant dependsOn references if you deploy virtual networks or public IP addresses in your template.

    {
      "apiVersion": "2021-03-01",
      "type": "Microsoft.Compute/cloudServices",
      "name": "[variables('cloudServiceName')]",
      "location": "[parameters('location')]",
      "tags": {
        "DeploymentLabel": "[parameters('deploymentLabel')]",
        "DeployFromVisualStudio": "true"
      },
      "dependsOn": [
        "[concat('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]",
        "[concat('Microsoft.Network/publicIPAddresses/', parameters('publicIPName'))]"
      ],
      "properties": {
        "packageUrl": "[parameters('packageSasUri')]",
        "configurationUrl": "[parameters('configurationSasUri')]",
        "upgradeMode": "[parameters('upgradeMode')]"
      }
    }
    
  4. Dağıtımınız için bir ağ profili nesnesi oluşturun ve genel IP adresini yük dengeleyicinin ön ucuyla ilişkilendirin. Azure platformu otomatik olarak bir yük dengeleyici oluşturur.

    "networkProfile": { 
        "loadBalancerConfigurations": [ 
          { 
            "id": "[concat(variables('resourcePrefix'), 'Microsoft.Network/loadBalancers/', variables('lbName'))]", 
            "name": "[variables('lbName')]", 
            "properties": { 
              "frontendIPConfigurations": [ 
                { 
                  "name": "[variables('lbFEName')]", 
                  "properties": { 
                    "publicIPAddress": { 
                      "id": "[concat(variables('resourcePrefix'), 'Microsoft.Network/publicIPAddresses/', parameters('publicIPName'))]" 
                    } 
                  } 
                } 
              ] 
            } 
          } 
        ] 
      } 
    
  5. ARM şablonunun osProfile bölümüne anahtar kasası referansınızı ekleyin. Anahtar kasası, Cloud Services (genişletilmiş destek) ile ilişkili sertifikaları depolar. Sertifikaları anahtar kasasına ekleyin ve yapılandırma (.cscfg) dosyasındaki sertifika parmak izlerine başvurun. Also, set the key vault access policy for Azure Virtual Machines for deployment in the Azure portal so that the Cloud Services (extended support) resource can retrieve the certificates that are stored as secrets in the key vault. The key vault must be in the same region and subscription as your Cloud Services (extended support) resource and have a unique name. Daha fazla bilgi için bkz. Cloud Services ile sertifikaları kullanma (genişletilmiş destek).

    "osProfile": { 
          "secrets": [ 
            { 
              "sourceVault": { 
                "id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.KeyVault/vaults/{keyvault-name}" 
              }, 
              "vaultCertificates": [ 
                { 
                  "certificateUrl": "https://{keyvault-name}.vault.azure.net:443/secrets/ContosoCertificate/{secret-id}" 
                } 
              ] 
            } 
          ] 
        } 
    

    Note

    sourceVaultin the ARM template is the value of the resource ID for your key vault. Anahtar kasanızın Özellikler bölümünde Kaynak Kimliği'nibularak bu bilgileri alabilirsiniz.

    • Anahtar kasasında certificateUrl etiketli sertifikaya giderek değerini alabilirsiniz. 
    • certificateUrl biçiminde https://{keyvault-endpoint}/secrets/{secret-name}/{secret-id}olmalıdır.
  6. Rol profili oluşturun. Rol sayısının, her roldeki örnek sayısının, rol adlarının ve rol boyutlarının yapılandırma (.cscfg) dosyası, tanım (.csdef) dosyası ve roleProfile ARM şablonundaki bölümde aynı olduğundan emin olun.

    "roleProfile": {
      "roles": {
        "value": [
          {
            "name": "WebRole1",
            "sku": {
              "name": "Standard_D1_v2",
              "capacity": "1"
            }
          },
          {
            "name": "WorkerRole1",
            "sku": {
              "name": "Standard_D1_v2",
              "capacity": "1"
            } 
          } 
        ]
      }
    }   
    
  7. (İsteğe bağlı) Cloud Services (genişletilmiş destek) dağıtımınıza uzantı eklemek için bir uzantı profili oluşturun. Aşağıdaki örnek Uzak Masaüstü Protokolü (RDP) uzantısını ve Azure Tanılama uzantısını ekler.

    Note

    RDP parolasının 8 ile 123 karakter arasında olması ve aşağıdaki parola karmaşıklığı gereksinimlerinin en az üçünün karşılanması gerekir:

    Contains an uppercase character.
    İçerisinde bir küçük harf karakteri bulunur.
    Sayısal bir rakam içerir.
    Özel bir karakter içerir.
    Denetim karakteri içeremez.

        "extensionProfile": {
          "extensions": [
            {
              "name": "RDPExtension",
              "properties": {
                "autoUpgradeMinorVersion": true,
                "publisher": "Microsoft.Windows.Azure.Extensions",
                "type": "RDP",
                "typeHandlerVersion": "1.2.1",
                "settings": "<PublicConfig>\r\n <UserName>[Insert Username]</UserName>\r\n <Expiration>1/21/2022 12:00:00 AM</Expiration>\r\n</PublicConfig>",
                "protectedSettings": "<PrivateConfig>\r\n <Password>[Insert Password]</Password>\r\n</PrivateConfig>"
              }
            },
            {
              "name": "Microsoft.Insights.VMDiagnosticsSettings_WebRole1",
              "properties": {
                "autoUpgradeMinorVersion": true,
                "publisher": "Microsoft.Azure.Diagnostics",
                "type": "PaaSDiagnostics",
                "typeHandlerVersion": "1.5",
                "settings": "[parameters('wadPublicConfig_WebRole1')]",
                "protectedSettings": "[parameters('wadPrivateConfig_WebRole1')]",
                "rolesAppliedTo": [
                  "WebRole1"
                ]
              }
            }
          ]
        }
    
  8. Şablonun tamamını gözden geçirin:

    {
      "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
        "cloudServiceName": {
          "type": "string",
          "metadata": {
            "description": "Name of the cloud service"
          }
        },
        "location": {
          "type": "string",
          "metadata": {
            "description": "Location of the cloud service"
          }
        },
        "deploymentLabel": {
          "type": "string",
          "metadata": {
            "description": "Label of the deployment"
          }
        },
        "packageSasUri": {
          "type": "securestring",
          "metadata": {
            "description": "SAS URI of the package (.cspkg) file to deploy"
          }
        },
        "configurationSasUri": {
          "type": "securestring",
          "metadata": {
            "description": "SAS URI of the configuration (.cscfg) file"
          }
        },
        "roles": {
          "type": "array",
          "metadata": {
            "description": "Roles created in the cloud service application"
          }
        },
        "wadPublicConfig_WebRole1": {
          "type": "string",
          "metadata": {
             "description": "Public configuration of the Azure Diagnostics extension"
          }
        },
        "wadPrivateConfig_WebRole1": {
          "type": "securestring",
          "metadata": {
            "description": "Private configuration of the Azure Diagnostics extension"
          }
        },
        "vnetName": {
          "type": "string",
          "defaultValue": "[concat(parameters('cloudServiceName'), 'VNet')]",
          "metadata": {
            "description": "Name of virtual network"
          }
        },
        "publicIPName": {
          "type": "string",
          "defaultValue": "contosocsIP",
          "metadata": {
            "description": "Name of public IP address"
          }
        },
        "upgradeMode": {
          "type": "string",
          "defaultValue": "Auto",
          "metadata": {
            "UpgradeMode": "UpgradeMode of the CloudService"
          }
        }
      },
      "variables": {
        "cloudServiceName": "[parameters('cloudServiceName')]",
        "subscriptionID": "[subscription().subscriptionId]",
        "dnsName": "[variables('cloudServiceName')]",
        "lbName": "[concat(variables('cloudServiceName'), 'LB')]",
        "lbFEName": "[concat(variables('cloudServiceName'), 'LBFE')]",
        "resourcePrefix": "[concat('/subscriptions/', variables('subscriptionID'), '/resourceGroups/', resourceGroup().name, '/providers/')]"
      },
      "resources": [
        {
          "apiVersion": "2019-08-01",
          "type": "Microsoft.Network/virtualNetworks",
          "name": "[parameters('vnetName')]",
          "location": "[parameters('location')]",
          "properties": {
            "addressSpace": {
              "addressPrefixes": [
                "10.0.0.0/16"
              ]
            },
            "subnets": [
              {
                "name": "WebTier",
                "properties": {
                  "addressPrefix": "10.0.0.0/24"
                }
              }
            ]
          }
        },
        {
          "apiVersion": "2019-08-01",
          "type": "Microsoft.Network/publicIPAddresses",
          "name": "[parameters('publicIPName')]",
          "location": "[parameters('location')]",
          "properties": {
            "publicIPAllocationMethod": "Dynamic",
            "idleTimeoutInMinutes": 10,
            "publicIPAddressVersion": "IPv4",
            "dnsSettings": {
              "domainNameLabel": "[variables('dnsName')]"
            }
          },
          "sku": {
            "name": "Basic"
          }
        },
        {
          "apiVersion": "2021-03-01",
          "type": "Microsoft.Compute/cloudServices",
          "name": "[variables('cloudServiceName')]",
          "location": "[parameters('location')]",
          "tags": {
            "DeploymentLabel": "[parameters('deploymentLabel')]",
            "DeployFromVisualStudio": "true"
          },
          "dependsOn": [
            "[concat('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]",
            "[concat('Microsoft.Network/publicIPAddresses/', parameters('publicIPName'))]"
          ],
          "properties": {
            "packageUrl": "[parameters('packageSasUri')]",
            "configurationUrl": "[parameters('configurationSasUri')]",
            "upgradeMode": "[parameters('upgradeMode')]",
            "roleProfile": {
              "roles": [
                {
                  "name": "WebRole1",
                  "sku": {
                    "name": "Standard_D1_v2",
                    "capacity": "1"
                  }
                },
                {
                  "name": "WorkerRole1",
                  "sku": {
                    "name": "Standard_D1_v2",
                    "capacity": "1"
                  }
                }
              ]
            },
            "networkProfile": {
              "loadBalancerConfigurations": [
                {
                  "id": "[concat(variables('resourcePrefix'), 'Microsoft.Network/loadBalancers/', variables('lbName'))]",
                  "name": "[variables('lbName')]",
                  "properties": {
                    "frontendIPConfigurations": [
                      {
                        "name": "[variables('lbFEName')]",
                        "properties": {
                          "publicIPAddress": {
                            "id": "[concat(variables('resourcePrefix'), 'Microsoft.Network/publicIPAddresses/', parameters('publicIPName'))]"
                          }
                        }
                      }
                    ]
                  }
                }
              ]
            },
            "osProfile": {
              "secrets": [
                {
                  "sourceVault": {
                    "id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.KeyVault/vaults/{keyvault-name}"
                  },
                  "vaultCertificates": [
                    {
                      "certificateUrl": "https://{keyvault-name}.vault.azure.net:443/secrets/ContosoCertificate/{secret-id}"
                    }
                  ]
                }
              ]
            },
            "extensionProfile": {
              "extensions": [
                {
                  "name": "RDPExtension",
                  "properties": {
                    "autoUpgradeMinorVersion": true,
                    "publisher": "Microsoft.Windows.Azure.Extensions",
                    "type": "RDP",
                    "typeHandlerVersion": "1.2.1",
                    "settings": "<PublicConfig>\r\n <UserName>[Insert Username]</UserName>\r\n <Expiration>1/21/2022 12:00:00 AM</Expiration>\r\n</PublicConfig>",
                    "protectedSettings": "<PrivateConfig>\r\n <Password>[Insert Password]</Password>\r\n</PrivateConfig>"
                  }
                },
                {
                  "name": "Microsoft.Insights.VMDiagnosticsSettings_WebRole1",
                  "properties": {
                    "autoUpgradeMinorVersion": true,
                    "publisher": "Microsoft.Azure.Diagnostics",
                    "type": "PaaSDiagnostics",
                    "typeHandlerVersion": "1.5",
                    "settings": "[parameters('wadPublicConfig_WebRole1')]",
                    "protectedSettings": "[parameters('wadPrivateConfig_WebRole1')]",
                    "rolesAppliedTo": [
                      "WebRole1"
                  ]
                }
              }
            ]
          }
        }
       }
      ]
    }
    
  9. Cloud Services (genişletilmiş destek) dağıtımını oluşturmak için şablon ve parametre dosyasını dağıtın (şablon dosyasında parametreleri tanımlamak için). Bu örnek şablonları kullanabilirsiniz.

    New-AzResourceGroupDeployment -ResourceGroupName "ContosOrg" -TemplateFile "file path to your template file" -TemplateParameterFile "file path to your parameter file"