链接ARM模板中的VMSS扩展

时间:2016-06-02 16:34:59

标签: azure azure-virtual-machine azure-resource-manager arm-template azure-vm-scale-set

我有一个包含5个扩展名的比例。其中2个用于Service Profiler,用于安装.net 4.6.1,以及用于Service Profiler代理本身。当我部署具有所有5个扩展的模板时,由于(我认为..)到.net安装需要重新启动vm,模板将始终导致失败状态。然而,它似乎并没有真正失败,因为当vm重新启动时,它会恢复任何尚未完成的扩展(再次,我认为......不幸的是,我的项目不在位置能够使用应用程序atm测试此基础架构。

因此,我试图将2个服务分析器扩展程序移动到链接模板,因此缩放集的状态将成功,此后的操作不会受到影响。 (以及模板中的其他资源依赖于规模集,我假设如果基础架构部署失败,VSTS发布管理器的应用程序部署将不会发生。)

因此,我的链接模板只具有比例集资源,但只定义了扩展名:

"resources": [
{
  "apiVersion": "2016-03-30",
  "type": "Microsoft.Compute/virtualMachineScaleSets",
  "name": "[variables('vmNodeType0Name')]",
  "location": "[resourceGroup().location]",
  "properties": {
    "virtualMachineProfile": {
      "extensionProfile": {
        "extensions": [
          {
            "properties": {
              "publisher": "Microsoft.Compute",
              "type": "CustomScriptExtension",
              "typeHandlerVersion": "1.7",
              "autoUpgradeMinorVersion": false,
              "settings": {
                "fileUris": [ "https://serviceprofiler.azurewebsites.net/content/downloads/InstallNetFx46.ps1" ],
                "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File InstallNetFx46.ps1"
              },
              "forceUpdateTag": "RerunExtension"
            },
            "name": "CustomScriptExtensionInstallNet46"
          },
          {
            "properties": {
              "publisher": "Microsoft.VisualStudio.ServiceProfiler",
              "type": "ServiceProfilerAgent",
              "typeHandlerVersion": "0.1",
              "autoUpgradeMinorVersion": true,
              "settings": {
                "config": {
                  "ServiceName": "<nameChanged>",
                  "CircularEtlBufferMB": 200,
                  "MonitorSamplingRate": 1.0,
                  "ProfileSamplingRate": 0.05,
                  "AgentLogFilter": "Warning",
                  "ProvideUsageTelemetryData": true,
                  "EtwMetrics": [
                    {
                      "ProviderName": "Microsoft-ServiceFabric-Actors",
                      "ProviderKeywords": 2,
                      "ProviderLevel": "Verbose",
                      "Event": "ActorMethod/Start",
                      "EventStop": "ActorMethod/Stop",
                      "Name": "methodName"
                    },
                    {
                      "ProviderName": "Microsoft-ServiceFabric-Actors",
                      "ProviderKeywords": 4,
                      "ProviderLevel": "Verbose",
                      "Event": "ActorSaveState/Start",
                      "EventStop": "ActorSaveState/Stop",
                      "Name": "actorType"
                    },
                    {
                      "ProviderName": "<nameChanged>",
                      "ProviderKeywords": 0,
                      "ProviderLevel": "Informational",
                      "Event": "Request/Start",
                      "EventStop": "Request/Stop",
                      "Name": "url"
                    }
                  ],
                  "Tags": [
                    {
                      "Type": "Performance",
                      "Settings": {
                        "SampleIntervalInSeconds": "5",
                        "SamplesToConsider": "6",
                        "Triggers": [
                          {
                            "Name": "High CPU",
                            "Description": "High CPU usage",
                            "PerfCounter": "Processor Information\\% Processor Time\\_Total",
                            "Operator": ">",
                            "Metric": "70"
                          },
                          {
                            "Name": "Busy Disk",
                            "Description": "High disk usage",
                            "PerfCounter": "PhysicalDisk\\% Disk Time\\_Total",
                            "Operator": ">",
                            "Metric": "10"
                          },
                          {
                            "Name": "Memory Pressure",
                            "Description": "High memory usage",
                            "PerfCounter": "Memory\\Available MBytes",
                            "Operator": "<",
                            "Metric": "400"
                          },
                          {
                            "Name": "High GC",
                            "Description": "High GC time",
                            "PerfCounter": ".NET CLR Memory\\% Time in GC\\_Global_",
                            "Operator": ">",
                            "Metric": "10"
                          }
                        ]
                      }
                    },
                    {
                      "Type": "Version",
                      "Settings": {
                        "Source": {
                          "Type": "ServiceFabric"
                        }
                      }
                    }
                  ]
                }
              },
              "protectedSettings": {
                "storageAccountName": "[variables('applicationDiagnosticsStorageAccountName')]",
                "storageAccountKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('applicationDiagnosticsStorageAccountName')),'2015-05-01-preview').key1]",
                "storageAccountEndPoint": "https://core.windows.net/"
              }
            },
            "name": "ServiceProfilerAgent"
          }
        ]
      }
    }
  }

但是,我收到此错误消息:

&#34; message&#34;:&#34; {\ r \ n \&#34;错误\&#34;:{\ r \ n \&#34;代码\&#34;: \&#34; OperationNotAllowed \&#34;,\ r \ n \&#34; message \&#34;:\&#34; VM Scale设置处理程序的扩展程序&#39; Microsoft.Azure.ServiceFabric.ServiceFabricNode& #39;只有在删除VM Scale Set时才能删除。\&#34; \ r \ n} \ r \ n}&#34;           },

考虑到我并没有尝试删除任何内容,似乎有点奇怪。而且据我所知,在关于链接模板中的扩展的文档中或其他任何地方都没有任何内容......

这甚至支持吗?或者我应该把它留在1个模板中? 任何帮助都会很棒!

2 个答案:

答案 0 :(得分:1)

关于删除扩展名的错误消息是因为扩展名列表是作为一个整体应用的,所以如果你没有两个原始扩展名(来自主模板),它会认为你正在删除它们。即您需要在列表中包含所有4个扩展名。 使用安装了.Net的自定义映像的注释中的建议是一个很好的建议。获取有关机器信息的另一个选择是使用customData属性 - 尽管它可能对这种特定情况没有帮助。

有一些要求创建安装了最新.Net的平台映像(我想知道市场中的任何一个图像是否已经有了这个),我认为我们应该这样做。

答案 1 :(得分:1)

这是我的完整比例集资源,单个模板中包含所有扩展名。它最初没有用,但它现在确实......

{
  "apiVersion": "[variables('vmssApiVersion')]",
  "type": "Microsoft.Compute/virtualMachineScaleSets",
  "name": "[parameters('vmNodeType0Name')]",
  "location": "[variables('computeLocation')]",
  "tags": {
    "resourceType": "node",
    "environmentName": "[parameters('prefix')]",
    "displayName": "[parameters('vmNodeType0DisplayName')]"
  },
  "dependsOn": [
    "storageLoop",
    "[variables('lbID0')]",
    "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]",
    "[concat('Microsoft.Storage/storageAccounts/', variables('supportLogStorageAccountName'))]",
    "[concat('Microsoft.Storage/storageAccounts/', variables('applicationDiagnosticsStorageAccountName'))]",
    "[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]",
    "[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'),'/Modules/',variables('dscModules').xNetworking.ModuleName)]",
    "[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'),'/Configurations/', parameters('configurationName'))]"
  ],
  "properties": {
    "overprovision": "[parameters('overProvision')]",
    "upgradePolicy": {
      "mode": "Automatic"
    },
    "virtualMachineProfile": {
      "extensionProfile": {
        "extensions": [
          {
            "properties": {
              "publisher": "Microsoft.Compute",
              "type": "CustomScriptExtension",
              "typeHandlerVersion": "1.7",
              "autoUpgradeMinorVersion": false,
              "settings": {
                "fileUris": [ "https://serviceprofiler.azurewebsites.net/content/downloads/InstallNetFx46.ps1" ],
                "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File InstallNetFx46.ps1"
              },
              "forceUpdateTag": "RerunExtension"
            },
            "name": "CustomScriptExtensionInstallNet46"
          },
          {
            "properties": {
              "publisher": "Microsoft.VisualStudio.ServiceProfiler",
              "type": "ServiceProfilerAgent",
              "typeHandlerVersion": "0.1",
              "autoUpgradeMinorVersion": true,
              "settings": {
                "config": {
                  "ServiceName": "<nameChanged>",
                  "CircularEtlBufferMB": 200,
                  "MonitorSamplingRate": 1.0,
                  "ProfileSamplingRate": 0.05,
                  "AgentLogFilter": "Warning",
                  "ProvideUsageTelemetryData": true,
                  "EtwMetrics": [
                    {
                      "ProviderName": "Microsoft-ServiceFabric-Actors",
                      "ProviderKeywords": 2,
                      "ProviderLevel": "Verbose",
                      "Event": "ActorMethod/Start",
                      "EventStop": "ActorMethod/Stop",
                      "Name": "methodName"
                    },
                    {
                      "ProviderName": "Microsoft-ServiceFabric-Actors",
                      "ProviderKeywords": 4,
                      "ProviderLevel": "Verbose",
                      "Event": "ActorSaveState/Start",
                      "EventStop": "ActorSaveState/Stop",
                      "Name": "actorType"
                    },
                    {
                      "ProviderName": "<nameChanged>",
                      "ProviderKeywords": 0,
                      "ProviderLevel": "Informational",
                      "Event": "Request/Start",
                      "EventStop": "Request/Stop",
                      "Name": "url"
                    }
                  ],
                  "Tags": [
                    {
                      "Type": "Performance",
                      "Settings": {
                        "SampleIntervalInSeconds": "5",
                        "SamplesToConsider": "6",
                        "Triggers": [
                          {
                            "Name": "High CPU",
                            "Description": "High CPU usage",
                            "PerfCounter": "Processor Information\\% Processor Time\\_Total",
                            "Operator": ">",
                            "Metric": "70"
                          },
                          {
                            "Name": "Busy Disk",
                            "Description": "High disk usage",
                            "PerfCounter": "PhysicalDisk\\% Disk Time\\_Total",
                            "Operator": ">",
                            "Metric": "10"
                          },
                          {
                            "Name": "Memory Pressure",
                            "Description": "High memory usage",
                            "PerfCounter": "Memory\\Available MBytes",
                            "Operator": "<",
                            "Metric": "400"
                          },
                          {
                            "Name": "High GC",
                            "Description": "High GC time",
                            "PerfCounter": ".NET CLR Memory\\% Time in GC\\_Global_",
                            "Operator": ">",
                            "Metric": "10"
                          }
                        ]
                      }
                    },
                    {
                      "Type": "Version",
                      "Settings": {
                        "Source": {
                          "Type": "ServiceFabric"
                        }
                      }
                    }
                  ]
                }
              },
              "protectedSettings": {
                "storageAccountName": "[variables('applicationDiagnosticsStorageAccountName')]",
                "storageAccountKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('applicationDiagnosticsStorageAccountName')),'2015-05-01-preview').key1]",
                "storageAccountEndPoint": "https://core.windows.net/"
              }
            },
            "name": "ServiceProfilerAgent"
          },
          {
            "name": "[concat(parameters('vmNodeType0Name'),'_ServiceFabricNode')]",
            "properties": {
              "type": "ServiceFabricNode",
              "autoUpgradeMinorVersion": false,
              "protectedSettings": {
                "StorageAccountKey1": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('supportLogStorageAccountName')),'2015-05-01-preview').key1]",
                "StorageAccountKey2": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('supportLogStorageAccountName')),'2015-05-01-preview').key2]"
              },
              "publisher": "Microsoft.Azure.ServiceFabric",
              "settings": {
                "clusterEndpoint": "[reference(parameters('clusterName')).clusterEndpoint]",
                "nodeTypeRef": "[parameters('vmNodeType0Name')]",
                "dataPath": "D:\\\\SvcFab",
                "durabilityLevel": "Bronze",
                "certificate": {
                  "thumbprint": "[parameters('certificateThumbprint')]",
                  "x509StoreName": "[parameters('certificateStoreValue')]"
                }
              },
              "typeHandlerVersion": "1.0"
            }
          },
          {
            "name": "[concat('VMDiagnosticsVmExt','_vmNodeType0Name')]",
            "properties": {
              "type": "IaaSDiagnostics",
              "autoUpgradeMinorVersion": true,
              "protectedSettings": {
                "storageAccountName": "[variables('applicationDiagnosticsStorageAccountName')]",
                "storageAccountKey": "[listkeys(variables('accountid'), '2015-05-01-preview').key1]",
                "storageAccountEndPoint": "https://core.windows.net/"
              },
              "publisher": "Microsoft.Azure.Diagnostics",
              "settings": {
                "WadCfg": {
                  "DiagnosticMonitorConfiguration": {
                    "overallQuotaInMB": "50000",
                    "EtwProviders": {
                      "EtwEventSourceProviderConfiguration": [
                        {
                          "provider": "Microsoft-ServiceFabric-Actors",
                          "scheduledTransferKeywordFilter": "1",
                          "scheduledTransferPeriod": "PT5M",
                          "DefaultEvents": {
                            "eventDestination": "ServiceFabricReliableActorEventTable"
                          }
                        },
                        {
                          "provider": "Microsoft-ServiceFabric-Services",
                          "scheduledTransferPeriod": "PT5M",
                          "DefaultEvents": {
                            "eventDestination": "ServiceFabricReliableServiceEventTable"
                          }
                        }
                      ],
                      "EtwManifestProviderConfiguration": [
                        {
                          "provider": "cbd93bc2-71e5-4566-b3a7-595d8eeca6e8",
                          "scheduledTransferLogLevelFilter": "Information",
                          "scheduledTransferKeywordFilter": "4611686018427387904",
                          "scheduledTransferPeriod": "PT5M",
                          "DefaultEvents": {
                            "eventDestination": "ServiceFabricSystemEventTable"
                          }
                        }
                      ]
                    }
                  }
                },
                "StorageAccount": "[variables('applicationDiagnosticsStorageAccountName')]"
              },
              "typeHandlerVersion": "1.5"
            }
          },
          {
            "name": "Microsoft.Powershell.DSC",
            "properties": {
              "publisher": "Microsoft.Powershell",
              "type": "DSC",
              "typeHandlerVersion": "2.17",
              "autoUpgradeMinorVersion": true,
              "protectedSettings": {
                "Items": {
                  "registrationKeyPrivate": "[parameters('registrationKey')]"
                }
              },
              "settings": {
                "WmfVersion": "latest",
                "ModulesUrl": "https://raw.github.com/Azure/azure-quickstart-templates/master/201-vmss-automation-dsc/UpdateLCMforAAPull.zip",
                "SasToken": "[parameters('_artifactsLocationSasToken')]",
                "ConfigurationFunction": "UpdateLCMforAAPull.ps1\\ConfigureLCMforAAPull",
                "Properties": [
                  {
                    "Name": "RegistrationKey",
                    "Value": {
                      "UserName": "[parameters('adminUserName')]",
                      "Password": "PrivateSettingsRef:registrationKeyPrivate"
                    },
                    "TypeName": "System.Management.Automation.PSCredential"
                  },
                  {
                    "Name": "RegistrationUrl",
                    "Value": "[parameters('registrationUrl')]",
                    "TypeName": "System.String"
                  },
                  {
                    "Name": "NodeConfigurationName",
                    "Value": "[parameters('nodeConfigurationName')]",
                    "TypeName": "System.String"
                  },
                  {
                    "Name": "ConfigurationMode",
                    "Value": "[parameters('configurationMode')]",
                    "TypeName": "System.String"
                  },
                  {
                    "Name": "ConfigurationModeFrequencyMins",
                    "Value": "[parameters('configurationModeFrequencyMins')]",
                    "TypeName": "System.Int32"
                  },
                  {
                    "Name": "RefreshFrequencyMins",
                    "Value": "[parameters('refreshFrequencyMins')]",
                    "TypeName": "System.Int32"
                  },
                  {
                    "Name": "RebootNodeIfNeeded",
                    "Value": "[parameters('rebootNodeIfNeeded')]",
                    "TypeName": "System.Boolean"
                  },
                  {
                    "Name": "ActionAfterReboot",
                    "Value": "[parameters('actionAfterReboot')]",
                    "TypeName": "System.String"
                  },
                  {
                    "Name": "AllowModuleOverwrite",
                    "Value": "[parameters('allowModuleOverwrite')]",
                    "TypeName": "System.Boolean"
                  },
                  {
                    "Name": "Timestamp",
                    "Value": "[parameters('timestamp')]",
                    "TypeName": "System.String"
                  }
                ]
              }
            }
          }
        ]
      },
      "networkProfile": {
        "networkInterfaceConfigurations": [
          {
            "name": "[concat(variables('nicName'), '-0')]",
            "properties": {
              "ipConfigurations": [
                {
                  "name": "[concat(variables('nicName'),'-',0)]",
                  "properties": {
                    "loadBalancerBackendAddressPools": [
                      {
                        "id": "[variables('lbPoolID0')]"
                      }
                    ],
                    "loadBalancerInboundNatPools": [
                      {
                        "id": "[variables('lbNatPoolID0')]"
                      }
                    ],
                    "subnet": {
                      "id": "[variables('subnet0Ref')]"
                    }
                  }
                }
              ],
              "primary": true
            }
          }
        ]
      },
      "osProfile": {
        "adminPassword": "[parameters('adminPassword')]",
        "adminUsername": "[parameters('adminUsername')]",
        "computernamePrefix": "[parameters('vmNodeType0Name')]",
        "secrets": [
          {
            "sourceVault": {
              "id": "[parameters('sourceVaultValue')]"
            },
            "vaultCertificates": [
              {
                "certificateStore": "[parameters('certificateStoreValue')]",
                "certificateUrl": "[parameters('certificateUrlValue')]"
              }
            ]
          }
        ]
      },
      "storageProfile": {
        "imageReference": {
          "publisher": "[parameters('vmImagePublisher')]",
          "offer": "[parameters('vmImageOffer')]",
          "sku": "[parameters('vmImageSku')]",
          "version": "[parameters('vmImageVersion')]"
        },
        "osDisk": {
          "vhdContainers": [
            "[concat('https://', variables('uniqueStringArray')[0], '.blob.core.windows.net/', parameters('vmStorageAccountContainerNameType0'))]",
            "[concat('https://', variables('uniqueStringArray')[1], '.blob.core.windows.net/', parameters('vmStorageAccountContainerNameType0'))]",
            "[concat('https://', variables('uniqueStringArray')[2], '.blob.core.windows.net/', parameters('vmStorageAccountContainerNameType0'))]",
            "[concat('https://', variables('uniqueStringArray')[3], '.blob.core.windows.net/', parameters('vmStorageAccountContainerNameType0'))]",
            "[concat('https://', variables('uniqueStringArray')[4], '.blob.core.windows.net/', parameters('vmStorageAccountContainerNameType0'))]"
          ],
          "name": "vmssosdisk",
          "caching": "ReadOnly",
          "createOption": "FromImage"
        }
      }
    }
  },
  "sku": {
    "name": "[parameters('vmNodeType0Size')]",
    "capacity": "5",
    "tier": "Standard"
  }
}