I keep seeing timeouts when using Azure Resource Manager to deploy a Service Fabric Cluster. I see the error below, probably about 20% of the time. Re-deploying the same configuration will fix the problem.
New-AzureRmResourceGroupDeployment : 6:54:02 AM - Resource Microsoft.Compute/virtualMachineScaleSets 'nodeType' failed
with message '{
"status": "Failed",
"error": {
"code": "ResourceDeploymentFailure",
"message": "The resource operation completed with terminal provisioning state 'Failed'.",
"details": [
{
"code": "VMExtensionHandlerNonTransientError",
"message": "Handler 'Microsoft.Azure.ServiceFabric.ServiceFabricNode' has reported failure for VM Extension
'nodeType_ServiceFabricNode' with terminal error code '1009' and error message: 'Enable failed for plugin (name:
Microsoft.Azure.ServiceFabric.ServiceFabricNode, version 1.0.0.35) with exception Command
C:\\Packages\\Plugins\\Microsoft.Azure.ServiceFabric.ServiceFabricNode\\1.0.0.35\\ServiceFabricExtensionHandler.exe of
Microsoft.Azure.ServiceFabric.ServiceFabricNode has not exited on time! Killing it...'"
}
]
}
}'
At C:\BuildAgent\work\d851d22c9abed7b9\Core\Core\scripts\Provision\ProvisionGeneric.ps1:39 char:1
+ New-AzureRmResourceGroupDeployment -Verbose -ResourceGroupName $resou ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDep
loymentCmdlet
New-AzureRmResourceGroupDeployment : 6:54:02 AM - Handler 'Microsoft.Azure.ServiceFabric.ServiceFabricNode' has
reported failure for VM Extension 'nodeType_ServiceFabricNode' with terminal error code '1009' and error message: 'Enable
failed for plugin (name: Microsoft.Azure.ServiceFabric.ServiceFabricNode, version 1.0.0.35) with exception Command
C:\Packages\Plugins\Microsoft.Azure.ServiceFabric.ServiceFabricNode\1.0.0.35\ServiceFabricExtensionHandler.exe of
Microsoft.Azure.ServiceFabric.ServiceFabricNode has not exited on time! Killing it...'
At C:\BuildAgent\work\d851d22c9abed7b9\Core\Core\scripts\Provision\ProvisionGeneric.ps1:39 char:1
+ New-AzureRmResourceGroupDeployment -Verbose -ResourceGroupName $resou ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDep
loymentCmdlet
The relevant part of the Azure RM template looks like this:
{
"apiVersion": "[variables('vmssApiVersion')]",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"name": "[parameters('vmNodeType0Name')]",
"location": "[parameters('computeLocation')]",
"dependsOn": ["[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
"[concat('Microsoft.Storage/storageAccounts/', variables('uniqueStringArray0')[0])]",
"[concat('Microsoft.Storage/storageAccounts/', variables('uniqueStringArray0')[1])]",
"[concat('Microsoft.Storage/storageAccounts/', variables('uniqueStringArray0')[2])]",
"[concat('Microsoft.Storage/storageAccounts/', variables('uniqueStringArray0')[3])]",
"[concat('Microsoft.Storage/storageAccounts/', variables('uniqueStringArray0')[4])]",
"[concat('Microsoft.Network/loadBalancers/', concat('INT_LB','-', parameters('clusterName'),'-',parameters('vmNodeType0Name')))]",
"[concat('Microsoft.Network/loadBalancers/', concat('EXT_LB','-', parameters('clusterName'),'-',parameters('vmNodeType0Name')))]",
"[concat('Microsoft.Storage/storageAccounts/', parameters('supportLogStorageAccountName'))]",
"[concat('Microsoft.Storage/storageAccounts/', parameters('applicationDiagnosticsStorageAccountName'))]"],
"properties": {
"overprovision": "[parameters('overProvision')]",
"upgradePolicy": {
"mode": "Automatic"
},
"virtualMachineProfile": {
"extensionProfile": {
"extensions": [{
"name": "[concat(parameters('vmNodeType0Name'),'_ServiceFabricNode')]",
"properties": {
"type": "ServiceFabricNode",
"autoUpgradeMinorVersion": false,
"protectedSettings": {
"StorageAccountKey1": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('supportLogStorageAccountName')),'2015-05-01-preview').key1]",
"StorageAccountKey2": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('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('clusterSecurityCertThumbprint')]",
"x509StoreName": "my"
}
},
"typeHandlerVersion": "1.0"
}
},
{
"name": "[concat('VMDiagnosticsVmExt','_vmNodeType0Name')]",
"properties": {
"type": "IaaSDiagnostics",
"autoUpgradeMinorVersion": true,
"protectedSettings": {
"storageAccountName": "[parameters('applicationDiagnosticsStorageAccountName')]",
"storageAccountKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('applicationDiagnosticsStorageAccountName')),'2015-05-01-preview').key1]",
"storageAccountEndPoint": "https://core.windows.net/"
},
"publisher": "Microsoft.Azure.Diagnostics",
"settings": {
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"overallQuotaInMB": "50000",
"sinks": "ApplicationInsights",
"DiagnosticInfrastructureLogs": {
"scheduledTransferLogLevelFilter": "Error"
},
"EtwProviders": {
"EtwEventSourceProviderConfiguration": [{
"provider": "Microsoft-ServiceFabric-Actors",
"scheduledTransferKeywordFilter": "1",
"scheduledTransferPeriod": "PT1M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableActorEvents"
}
},
{
"provider": "Microsoft-ServiceFabric-Services",
"scheduledTransferPeriod": "PT1M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableServiceEvents"
}
}],
"EtwManifestProviderConfiguration": [{
"provider": "cbd93bc2-71e5-4566-b3a7-595d8eeca6e8",
"scheduledTransferLogLevelFilter": "Information",
"scheduledTransferKeywordFilter": "4611686018427387904",
"scheduledTransferPeriod": "PT1M",
"DefaultEvents": {
"eventDestination": "ServiceFabricSystemEventTable"
}
}]
}
},
"SinksConfig": {
"Sink": [{
"name": "ApplicationInsights",
"ApplicationInsights": "[parameters('appInsightsKey')]",
"Channels": {
"Channel": [{
"logLevel": "Error",
"name": "Errors"
},
{
"logLevel": "Verbose",
"name": "AppLogs"
}]
}
}]
}
},
"StorageAccount": "[parameters('applicationDiagnosticsStorageAccountName')]"
},
"typeHandlerVersion": "1.5"
}
}]
},
"networkProfile": {
"networkInterfaceConfigurations": [{
"name": "[concat(parameters('nicName'), '-0')]",
"properties": {
"ipConfigurations": [{
"name": "[concat(parameters('nicName'),'-',0)]",
"properties": {
"loadBalancerBackendAddressPools": [{
"id": "[variables('lbIntPoolId')]"
},
{
"id": "[variables('lbExtPoolId')]"
}],
"subnet": {
"id": "[variables('subnet0Ref')]"
}
}
}],
"primary": true
}
}]
},
"osProfile": {
"adminPassword": "[parameters('adminPassword')]",
"adminUsername": "[parameters('adminUsername')]",
"computernamePrefix": "[parameters('vmNodeType0Name')]",
"secrets": [{
"sourceVault": {
"id": "[parameters('keyVaultName')]"
},
"vaultCertificates": [{
"certificateStore": "my",
"certificateUrl": "[parameters('encyphermentCertId')]"
},
{
"certificateStore": "my",
"certificateUrl": "[parameters('identityServerSigningCertId')]"
},
{
"certificateStore": "my",
"certificateUrl": "[parameters('clusterSecurityCertId')]"
},
{
"certificateStore": "My",
"certificateUrl": "[parameters('adminCertId')]"
},
{
"certificateStore": "CertificateAuthority",
"certificateUrl": "[parameters('clusterSecurityCertId')]"
}]
}]
},
"storageProfile": {
"imageReference": {
"publisher": "[parameters('vmImagePublisher')]",
"offer": "[parameters('vmImageOffer')]",
"sku": "[parameters('vmImageSku')]",
"version": "[parameters('vmImageVersion')]"
},
"osDisk": {
"vhdContainers": ["[concat('https://', variables('uniqueStringArray0')[0], '.blob.core.windows.net/', parameters('vmStorageAccountContainerName'))]",
"[concat('https://', variables('uniqueStringArray0')[1], '.blob.core.windows.net/', parameters('vmStorageAccountContainerName'))]",
"[concat('https://', variables('uniqueStringArray0')[2], '.blob.core.windows.net/', parameters('vmStorageAccountContainerName'))]",
"[concat('https://', variables('uniqueStringArray0')[3], '.blob.core.windows.net/', parameters('vmStorageAccountContainerName'))]",
"[concat('https://', variables('uniqueStringArray0')[4], '.blob.core.windows.net/', parameters('vmStorageAccountContainerName'))]"],
"name": "vmssosdisk",
"caching": "ReadOnly",
"createOption": "FromImage"
}
}
}
},
"sku": {
"name": "[parameters('vmNodeType0Size')]",
"capacity": "[parameters('vmNodeType0Count')]",
"tier": "Standard"
},
"tags": {
"resourceType": "Service Fabric",
"clusterName": "[parameters('clusterName')]"
}
},
It seems to happen more in the morning than any other time. It's causing our CI build to fail on a regular basis. How can I diagnose this problem? If it's just something we should expect, then what is the best way to capture the error to force a re-deploy?
If you're not changing anything between deployments it's not likely anything you're doing wrong... Open a support request in the Azure portal and give them one of your correlationIds from the failed deployments (more if you have 'em).
Related
We are trying to deploy Azure Linux App Service, that also has mounted storage. Here's our ARM template
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"Environment": {
"type": "String",
"allowedValues": [
"dev",
"stg",
"prd"
]
},
"Region": {
"type": "string",
"allowedValues": [
"eu",
"we"
]
},
"MagentoMediaFileShareName": {
"type": "string"
},
"StorageAccountName": {
"type": "string"
},
"StorageAccountAccessKey": {
"type": "securestring"
},
"MagentoMediaMountPath": {
"type": "string",
"defaultValue": "/var/www/html/pub/external_media"
}
},
"variables": {
"Location": "[resourceGroup().location]",
"ResourcePrefix": "[format('ariva-{0}-{1}-magento', parameters('Environment'), parameters('Region'))]",
"WebSiteName": "[concat(variables('ResourcePrefix'), '-web')]",
"ServicePlanId": "[format('/subscriptions/{0}/resourceGroups/ariva-{1}-{2}/providers/Microsoft.Web/serverfarms/ariva-{1}-{2}-asp', subscription().subscriptionId, parameters('Environment'), parameters('Region'))]"
},
"resources": [
{
"type": "Microsoft.Web/sites",
"apiVersion": "2020-12-01",
"name": "[variables('WebSiteName')]",
"location": "[variables('Location')]",
"kind": "app,linux,container",
"properties": {
"enabled": true,
"hostNameSslStates": [
{
"name": "[concat(variables('WebSiteName'), '.azurewebsites.net')]",
"sslState": "Disabled",
"hostType": "Standard"
},
{
"name": "[concat(variables('WebSiteName'), '.scm.azurewebsites.net')]",
"sslState": "Disabled",
"hostType": "Repository"
}
],
"serverFarmId": "[variables('ServicePlanId')]",
"reserved": true,
"isXenon": false,
"hyperV": false,
"siteConfig": {
"numberOfWorkers": 1,
"linuxFxVersion": "DOCKER|mcr.microsoft.com/appsvc/staticsite:latest",
"acrUseManagedIdentityCreds": false,
"alwaysOn": false,
"http20Enabled": false,
"functionAppScaleLimit": 0,
"minimumElasticInstanceCount": 1
},
"scmSiteAlsoStopped": false,
"clientAffinityEnabled": false,
"clientCertEnabled": false,
"clientCertMode": "Required",
"hostNamesDisabled": false,
"customDomainVerificationId": "1071794BD68C78EC0A4569F03C034F6E1B21BD4E6D35725D99523AC00AE12AA1",
"containerSize": 0,
"dailyMemoryTimeQuota": 0,
"keyVaultReferenceIdentity": "SystemAssigned",
"httpsOnly": false,
"redundancyMode": "None",
"storageAccountRequired": false
}
},
{
"type": "Microsoft.Web/sites/basicPublishingCredentialsPolicies",
"apiVersion": "2020-12-01",
"name": "[concat(variables('WebSiteName'), '/ftp')]",
"location": "[variables('Location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('WebSiteName'))]"
],
"properties": {
"allow": true
}
},
{
"type": "Microsoft.Web/sites/basicPublishingCredentialsPolicies",
"apiVersion": "2020-12-01",
"name": "[concat(variables('WebSiteName'), '/scm')]",
"location": "[variables('Location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('WebSiteName'))]"
],
"properties": {
"allow": true
}
},
{
"type": "Microsoft.Web/sites/config",
"apiVersion": "2020-12-01",
"name": "[concat(variables('WebSiteName'), '/web')]",
"location": "[variables('Location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('WebSiteName'))]"
],
"properties": {
"numberOfWorkers": 1,
"defaultDocuments": [
"Default.htm",
"Default.html",
"Default.asp",
"index.htm",
"index.html",
"iisstart.htm",
"default.aspx",
"index.php",
"hostingstart.html"
],
"netFrameworkVersion": "v4.0",
"linuxFxVersion": "DOCKER|mcr.microsoft.com/appsvc/staticsite:latest",
"requestTracingEnabled": false,
"remoteDebuggingEnabled": false,
"remoteDebuggingVersion": "VS2019",
"httpLoggingEnabled": false,
"acrUseManagedIdentityCreds": false,
"logsDirectorySizeLimit": 35,
"detailedErrorLoggingEnabled": false,
"publishingUsername": "[concat('$', variables('WebSiteName'))]",
"azureStorageAccounts": {
"magento-media": {
"type": "AzureFiles",
"accountName": "[parameters('StorageAccountName')]",
"shareName": "[parameters('MagentoMediaFileShareName')]",
"mountPath": "[parameters('MagentoMediaMountPath')]",
"accessKey": "[parameters('StorageAccountAccessKey')]"
}
},
"scmType": "None",
"use32BitWorkerProcess": true,
"webSocketsEnabled": true,
"alwaysOn": true,
"managedPipelineMode": "Integrated",
"virtualApplications": [
{
"virtualPath": "/",
"physicalPath": "site\\wwwroot",
"preloadEnabled": false
}
],
"loadBalancing": "LeastRequests",
"experiments": {
"rampUpRules": []
},
"autoHealEnabled": false,
"vnetRouteAllEnabled": false,
"vnetPrivatePortsCount": 0,
"localMySqlEnabled": false,
"ipSecurityRestrictions": [
{
"ipAddress": "Any",
"action": "Allow",
"priority": 1,
"name": "Allow all",
"description": "Allow all access"
}
],
"scmIpSecurityRestrictions": [
{
"ipAddress": "Any",
"action": "Allow",
"priority": 1,
"name": "Allow all",
"description": "Allow all access"
}
],
"scmIpSecurityRestrictionsUseMain": false,
"http20Enabled": true,
"minTlsVersion": "1.2",
"scmMinTlsVersion": "1.0",
"ftpsState": "AllAllowed",
"preWarmedInstanceCount": 0,
"functionAppScaleLimit": 0,
//"healthCheckPath": "/health_check.php",
"functionsRuntimeScaleMonitoringEnabled": false,
"minimumElasticInstanceCount": 1
}
},
{
"type": "Microsoft.Web/sites/hostNameBindings",
"apiVersion": "2020-12-01",
"name": "[concat(variables('WebSiteName'), '/', variables('WebSiteName'), '.azurewebsites.net')]",
"location": "[variables('Location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('WebSiteName'))]"
],
"properties": {
"siteName": "[variables('WebSiteName')]",
"hostNameType": "Verified"
}
}
]
}
If we execute this exact template, we will receive the following error
{
"status": "Failed",
"error": {
"code": "BadRequest",
"message": "Required parameter AccessKey is missing.",
"details": [
{
"message": "Required parameter AccessKey is missing."
},
{
"code": "BadRequest"
},
{}
]
}
}
We receive the same error if we have storage manually mounted through portal and try to change the configurations or add deployment slots.
As soon as I remove the mounted storage configuration, everything works just fine.
We need to have this in our DevOps pipeline, it's not acceptable that we unmount-remount the storage manually before and after the deployments. That would cause major issues and downtime. What can we do to overcome the issue?
UPDATE 1
I've tried to create a totally separate web app and storage account all manually. As soon as I hooked the storage mount and tried to enable health checks for instance, I got the same error. I think there's a bug in Azure.
UPDATE 2
Here is the template that deploys the dependent storage account
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"Environment": {
"type": "String",
"allowedValues": [
"dev",
"stg",
"prd"
]
},
"Region": {
"type": "string",
"allowedValues": [
"eu",
"we"
]
}
},
"variables": {
"Location": "[resourceGroup().location]",
"StorageAccountName": "[format('ariva{0}{1}magentostorage', parameters('Environment'), parameters('Region'))]",
"MagentoMediaFileShareName": "magento-media"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-04-01",
"name": "[variables('StorageAccountName')]",
"location": "[variables('Location')]",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"allowCrossTenantReplication": true,
"minimumTlsVersion": "TLS1_2",
"allowBlobPublicAccess": true,
"allowSharedKeyAccess": true,
"networkAcls": {
"resourceAccessRules": [],
"bypass": "AzureServices",
"virtualNetworkRules": [],
"ipRules": [],
"defaultAction": "Allow"
},
"supportsHttpsTrafficOnly": true,
"encryption": {
"services": {
"file": {
"keyType": "Account",
"enabled": true
},
"blob": {
"keyType": "Account",
"enabled": true
}
},
"keySource": "Microsoft.Storage"
},
"accessTier": "Hot"
}
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "2021-04-01",
"name": "[concat(variables('StorageAccountName'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccountName'))]"
],
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"properties": {
"changeFeed": {
"enabled": false
},
"restorePolicy": {
"enabled": false
},
"containerDeleteRetentionPolicy": {
"enabled": true,
"days": 7
},
"cors": {
"corsRules": []
},
"deleteRetentionPolicy": {
"enabled": true,
"days": 7
},
"isVersioningEnabled": false
}
},
{
"type": "Microsoft.Storage/storageAccounts/fileServices",
"apiVersion": "2021-04-01",
"name": "[concat(variables('StorageAccountName'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccountName'))]"
],
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"properties": {
"shareDeleteRetentionPolicy": {
"enabled": true,
"days": 7
}
}
},
{
"type": "Microsoft.Storage/storageAccounts/queueServices",
"apiVersion": "2021-04-01",
"name": "[concat(variables('StorageAccountName'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccountName'))]"
],
"properties": {
"cors": {
"corsRules": []
}
}
},
{
"type": "Microsoft.Storage/storageAccounts/tableServices",
"apiVersion": "2021-04-01",
"name": "[concat(variables('StorageAccountName'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccountName'))]"
],
"properties": {
"cors": {
"corsRules": []
}
}
},
{
"type": "Microsoft.Storage/storageAccounts/fileServices/shares",
"apiVersion": "2021-04-01",
"name": "[concat(variables('StorageAccountName'), '/default/', variables('MagentoMediaFileShareName'))]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/fileServices', variables('StorageAccountName'), 'default')]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccountName'))]"
],
"properties": {
"accessTier": "TransactionOptimized",
"shareQuota": 5120,
"enabledProtocols": "SMB"
}
}
],
"outputs": {
"MagentoMediaFileShareName": {
"type": "string",
"value": "[variables('MagentoMediaFileShareName')]"
},
"StorageAccountName": {
"type": "string",
"value": "[variables('StorageAccountName')]"
},
"StorageAccountAccessKey": {
"type": "securestring",
"value": "[listKeys(variables('StorageAccountName'), '2019-04-01').keys[0].value]"
}
}
}
UPDATE 3 - temporary workaround
We were able to find a temporary workaround. Instead of deploying the file mount through the ARM template, we've removed that bit from ARM template, after, we use the following build step in our DevOps pipeline to mount the storage through azure CLI
- task: AzureCLI#2
displayName: 'Attach media volume'
inputs:
azureSubscription: '${{ parameters.azureSubscription }}'
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
az webapp config storage-account add `
--resource-group ${{ parameters.resourceGroup }} `
--name "$(WebSiteName)" `
--access-key "$(StorageAccountAccessKey)" `
--custom-id magento-media `
--storage-type AzureFiles `
--share-name "$(MagentoMediaFileShareName)" `
--account-name "$(StorageAccountName)" `
--mount-path "/var/www/html/pub/external_media"
This doesn't solve the problem of course.
Doing so, ARM template will essentially remove the mount and then it will be deployed by the script, causing downtime
When mount is in place, we still can't change any of the WebApp properties through the portal and we will get the error that AccessKey is missing
azureStorageAccounts is not part of Microsoft.Web sites/config 2020-12-01 however it is under Microsoft.Web sites 2020-12-01 SiteConfig property. This may be the reason accessKey wasn't found, wasn't uploaded. I would move azureStorageAccounts under siteConfig
I'm trying to have a single playbook that will create a VM in Azure and also run a playbook on it once it is created.
I can get the VM to be created but as the Public IP doesn't exist before it is created I can't use for the inventory. This is my current yaml:
---
- hosts: localhost
tasks:
- name: Create virtual network
azure_rm_virtualnetwork:
resource_group: az-test
name: az-test-vnet
address_prefixes: "10.43.0.0/16"
- name: Add subnet
azure_rm_subnet:
resource_group: az-test
name: az-test-subnet
address_prefix: "10.43.0.0/24"
virtual_network: az-test-vnet
- name: Create VM
azure_rm_virtualmachine:
resource_group: az-test
name: az-test-vm
vm_size: Standard_DS1_v2
admin_username: az-test
ssh_password_enabled: false
ssh_public_keys:
- path: /home/az-test/.ssh/authorized_keys
key_data: "ssh-rsa xxxx "
image:
offer: CentOS
publisher: OpenLogic
sku: '7.4'
version: latest
#- name: Get facts for all Public IPs within a resource groups
# azure_rm_publicip_facts:
# resource_group: az-test
The last bit there's an Ansible Azure module that should return all public IPs in the resource group but that fails.
Even if I could dynamically retrive the Public IP address, could the playbook even be run on it as ansible-playbook was initially only run on 'localhost' and the Public IP is not in the inventory?
Using latest of everything:
ansible 2.4.3.0
python 2.7
azure-cli-core-2.0.31
Apologies for the messy YAML formatting..
EDIT:
Can see Ansible is gathering facts that I can use but not exactly sure how to reference them?
"ansible_facts": {
"azure_vm": {
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Compute/virtualMachines/az-test",
"location": "eastus",
"name": "az-test",
"powerstate": "running",
"properties": {
"hardwareProfile": {
"vmSize": "Standard_DS1_v2"
},
"instanceView": {
"disks": [
{
"name": "az-test.vhd",
"statuses": [
{
"code": "ProvisioningState/succeeded",
"displayStatus": "Provisioning succeeded",
"level": "Info",
"time": "2018-04-16Tx"
}
]
}
],
"extensions": [
{
"name": "OmsAgentForLinux",
"statuses": [
{
"code": "ProvisioningState/succeeded",
"displayStatus": "Provisioning succeeded",
"level": "Info",
"message": "Enable succeeded"
}
],
"type": "Microsoft.EnterpriseCloud.Monitoring.OmsAgentForLinux",
"typeHandlerVersion": "1.4.60.2"
}
],
"statuses": [
{
"code": "ProvisioningState/succeeded",
"displayStatus": "Provisioning succeeded",
"level": "Info",
"time": "2018-04-16Tx"
},
{
"code": "PowerState/running",
"displayStatus": "VM running",
"level": "Info"
}
],
"vmAgent": {
"extensionHandlers": [
{
"status": {
"code": "ProvisioningState/succeeded",
"displayStatus": "Ready",
"level": "Info",
"message": "Plugin enabled"
},
"type": "Microsoft.EnterpriseCloud.Monitoring.OmsAgentForLinux",
"typeHandlerVersion": "1.4.60.2"
}
],
"statuses": [
{
"code": "ProvisioningState/succeeded",
"displayStatus": "Ready",
"level": "Info",
"message": "Guest Agent is running",
"time": "2018-04-16Tx"
}
],
"vmAgentVersion": "2.2.25"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Network/networkInterfaces/az-test01",
"name": "az-test01",
"properties": {
"dnsSettings": {
"appliedDnsServers": [],
"dnsServers": [],
"internalDomainNameSuffix": "x.bx.internal.cloudapp.net"
},
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"ipConfigurations": [
{
"etag": "W/\"x\"",
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Network/networkInterfaces/az-test01/ipConfigurations/default",
"name": "default",
"properties": {
"primary": true,
"privateIPAddress": "10.43.0.5",
"privateIPAddressVersion": "IPv4",
"privateIPAllocationMethod": "Dynamic",
"provisioningState": "Succeeded",
"publicIPAddress": {
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Network/publicIPAddresses/az-test01",
"name": "az-test01",
"properties": {
"idleTimeoutInMinutes": 4,
"ipAddress": "52.x.x.x",
"ipConfiguration": {
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Network/networkInterfaces/az-test01/ipConfigurations/default"
},
"provisioningState": "Succeeded",
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Static",
"resourceGuid": "x"
}
},
"subnet": {
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Network/virtualNetworks/az-test-vnet/subnets/az-test-subnet"
}
}
}
],
"macAddress": "00-0D-3A-1D-E1-8A",
"networkSecurityGroup": {
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Network/networkSecurityGroups/az-test01"
},
"primary": true,
"provisioningState": "Succeeded",
"resourceGuid": "x",
"virtualMachine": {
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Compute/virtualMachines/az-test"
}
}
}
]
},
"osProfile": {
"adminUsername": "az-test",
"computerName": "az-test",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"keyData": "ssh-rsa AAx ",
"path": "/home/az-test/.ssh/authorized_keys"
}
]
}
},
"secrets": []
},
"provisioningState": "Succeeded",
"storageProfile": {
"dataDisks": [],
"imageReference": {
"offer": "CentOS",
"publisher": "OpenLogic",
"sku": "7.4",
"version": "7.4.20180118"
},
"osDisk": {
"caching": "ReadOnly",
"createOption": "fromImage",
"diskSizeGB": 30,
"name": "az-test.vhd",
"osType": "Linux",
"vhd": {
"uri": "https://x.blob.core.windows.net/vhds/az-test.vhd"
}
}
},
"vmId": "x"
},
"resources": [
{
"id": "/subscriptions/x/resourceGroups/az-test/providers/Microsoft.Compute/virtualMachines/az-test/extensions/OmsAgentForLinux",
"location": "eastus",
"name": "OmsAgentForLinux",
"properties": {
"autoUpgradeMinorVersion": true,
"provisioningState": "Succeeded",
"publisher": "Microsoft.EnterpriseCloud.Monitoring",
"settings": {
"azureResourceId": "/subscriptions/x/resourcegroups/az-test/providers/microsoft.compute/virtualmachines/az-test",
"stopOnMultipleConnections": true,
"workspaceId": "x"
},
"type": "OmsAgentForLinux",
"typeHandlerVersion": "1.0"
},
"type": "Microsoft.Compute/virtualMachines/extensions"
}
],
"tags": {},
"type": "Microsoft.Compute/virtualMachines"
}
}
The module name should be azure_rm_publicipaddress_facts instead of azure_rm_publicip_facts
I have a very simple ARM template which spins up an app service plan and a website. When I delete plan or resource group it works fine and creates new plan and website. Following is the template:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"environment": {
"type": "string",
"metadata": {
"comments": "The environment to suffix to distinguish resources in different groups"
}
"allowedValues": ["Test","Uat","Stage"]
},
"planName": {
"type": "string"
},
/*Other Parameters*/
}
},
"variables": {
"planNameFull": /*expression*/,
"siteTestNameFull": /*expression*/,
"appDomainName": /*expression*/
},
"resources": [
{
"comments": "Application Plan (Serverfarm)",
"type": "Microsoft.Web/serverfarms",
"sku": {
"name": "S1",
"tier": "Standard",
"Size": "S1",
"family": "S",
"capacity": "1"
},
"kind": "app",
"name": "[variables('planNameFull')]",
"apiVersion": "2016-09-01",
"location": "[resourceGroup().location]",
"tags": {
"[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('planNameFull'))]": "empty",
"displayName": "[variables('planNameFull')]"
},
"properties": {
"name": "[variables('planNameFull')]",
"workerTierName": null,
"adminSiteName": null,
"hostingEnvironmentProfile": null,
"perSiteScaling": false,
"reserved": false,
"targetWorkerCount": 0,
"targetWorkerSizeId": 0
}
},
{
"comments": "Test Web Site",
"type": "Microsoft.Web/sites",
"kind": "app",
"name": "[variables('siteTestNameFull')]",
"apiVersion": "2016-08-01",
"location": "[resourceGroup().location]",
"tags": {
"[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('planNameFull'))]": "empty",
"displayName": "[variables('siteTestNameFull')]"
},
"properties": {
"clientAffinityEnabled": true,
"enabled": true,
"hostNameSslStates": [
{
"name:": "[concat(variables('siteTestNameFull') ,'.azurewebsites.net')]",
"sslState": "Disabled",
"hostType": "Standard"
},
{
"name:": "[concat(variables('siteTestNameFull') ,'scm.azurewebsites.net')]",
"sslState": "Disabled",
"hostType": "Repository"
}
],
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms',variables('planNameFull'))]"
},
"dependsOn": [ "[resourceId('Microsoft.Web/serverfarms',variables('planNameFull'))]" ],
"resources": [
{
"comments": "Test Web Site Config.",
"type": "Microsoft.Web/sites/config",
"name": "[concat(variables('siteTestNameFull'),'/web')]",
"apiVersion": "2015-08-01",
"tags": {
"[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('planNameFull'))]": "empty",
"description": "[concat('Moula ', variables('siteTestNameFull'),' Settings')]",
"displayName": "[concat(variables('siteTestNameFull'),' App Settings')]"
},
"properties": {
"numberOfWorkers": 1,
"defaultDocuments": [ "index.html" ],
"netFrameworkVersion": "v4.7",
"publishingUsername": "[parameters('webPublishingUser')]",
"publishingPassword": "[parameters('webPublishingPwd')]",
"siteAuthSettings": { "isAadAutoProvisioned": false },
"ipSecurityRestrictions": [
{
"ipAddress": "115.xx.xxx.27",
"subnetMask": null
},
{
"ipAddress": "34.xxx.xx.90",
"subnetMask": null
}
],
"appSettings": {
"WEBSITE_TIME_ZONE": "[parameters('websiteTimezone')]",
"WEBSITE_LOAD_CERTIFICATES": "[parameters('testCertificate')]"
},
"use32BitWorkerProcess": false,
"managedPipelineMode": "Integrated",
"virtualApplications": [
{
"virtualPath": "/",
"physicalPath": "site\\wwwroot",
"preloadEnabled": false,
"vitualDirectories": null
}
],
"loadBalancingRules": [ "LeastRequests" ]
},
"dependsOn": [ "[resourceId('Microsoft.Web/sites',variables('siteTestNameFull'))]" ]
}
]
}
],
"outputs": {
"planId": {
"type": "string",
"value": "[resourceId('Microsoft.Web/serverfarms', variables('planNameFull'))]"
},
"TestAppId": {
"type": "string",
"value": "[resourceId('Microsoft.Web/sites',variables('siteTestNameFull'))]"
}
}
}
My problem is that I want to run this template as VSTS build pipeline step. When I try to run template again without making any changes, it causes following error always:
Template deployment returned the following errors:
1:09:17 PM - Resource Microsoft.Web/sites 'TestWebsite' failed with message '{
"error": {
"code": "InternalServerError",
"message": "There was an unexpected InternalServerError. Please try again later. x-ms-correlation-request-id: 8cd06d54-vvvv-wwww-xxxx-5e55029fc640"
}
}'
What I'm doing wrong?
There are multiple reasons for this type of error. This is the official documenation.
Downtime of either the service you're deploying to in the region you're deploying to.
Downtime of Azure DevOps itself.
The resource type you're trying to deploy isn't yet available in that region.
I have a scale set with 5 extensions. 2 of them are for Service Profiler, to install .net 4.6.1, and for the service profiler agent itself. When I deploy the template with all 5 extensions, due (I think..) to the .net installation requiring a restart of the vm, the template will always result in a status of failed. However, it doesn't seem to have actually failed, as when the vm restarts, it resumes any extensions that haven't finished (again, I think.. Unfortunately, my project isn't in the position to be able to test this infrastructure with an application atm).
So, I have attempted to move the 2 service profiler extensions to a linked template, so the status of the scale set will go to succeeded, and actions after this won't be impacted. (As well as other resources in the template being dependent on the scale set, I assume application deployment from VSTS release manager won't happen if the infrastructure deployment 'failed'.)
So my linked template simply has the scale set resource, but with only the extensions defined:
"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"
}
]
}
}
}
However, I get this error message:
"message": "{\r\n \"error\": {\r\n \"code\": \"OperationNotAllowed\",\r\n \"message\": \"VM Scale Set extensions of handler 'Microsoft.Azure.ServiceFabric.ServiceFabricNode' can be deleted only at the time of VM Scale Set deletion.\"\r\n }\r\n}"
},
Seems kind of strange considering I'm not trying to delete anything. And ofc there is literally nothing, as far as I can tell, in the documentation about extensions in linked templates, or anywhere else...
Is this even supported? Or should I just leave it in 1 template?
Any help would be great!
the error message about deleting extensions is because the extension list is applied as a whole, so if you don't have the two original extensions (from the main template) it will think you are deleting them. I.e. you'd need to include all 4 extensions in the list.
The suggestion in the comments of using a custom image with .Net installed is a good one. Another option for getting information on to the machine is to use the customData property - though it probably won't help this specific case.
There are some requests to create a platform image with latest .Net installed (I'm wondering whether any of the marketplace images already have this), and I think we should do it.
Here is my full scale set resource, with all extensions in the single template. It originally didn't work, but it does now...
{
"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"
}
}
I have a Azure Resource Manager Template that is part of a set of nested templates. It creates a App Insights component, an alert rule against the website for forbidden requests, a multistep web test, and an alert rule against the web test. All the resources except the alert rule against the web test deploy successfully. I can go into the portal and create the alert against the test without issue after the deployment fails.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"company": {
"type": "string"
},
"region": {
"type": "string"
},
"retailerAPIKey": {
"type": "string"
},
"deviceID": {
"type": "string"
},
"lumicastVersion": {
"type": "string"
}
},
"variables": {
"frameworkWebSite": "[concat(parameters('company'),'-BLS-FRAMEWORK-',parameters('region'))]"
},
"resources": [
{
"name": "[concat('ForbiddenRequests ', variables('frameworkWebSite'))]",
"type": "Microsoft.Insights/alertrules",
"location": "[parameters('region')]",
"apiVersion": "2014-04-01",
"tags": {
"displayName": "ForbiddenRequests frameworkWebSite"
},
"properties": {
"name": "[concat('ForbiddenRequests ', variables('frameworkWebSite'))]",
"description": "[concat(variables('frameworkWebSite'), ' has some requests that are forbidden, status code 403.')]",
"isEnabled": false,
"condition": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri": "[concat(resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('frameworkWebSite'))]",
"metricName": "Http403"
},
"operator": "GreaterThan",
"threshold": 0,
"windowSize": "PT5M"
},
"action": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners": true,
"customEmails": [ ]
}
}
},
{
"name": "[variables('frameworkWebSite')]",
"type": "Microsoft.Insights/components",
"location": "Central US",
"apiVersion": "2014-04-01",
"tags": {
"displayName": "Component frameworkWebSite",
"[concat('hidden-link:',resourceGroup().id,'/providers/Microsoft.Web/sites/',variables('frameworkWebSite'))]": "Resource"
},
"properties": {
"applicationId": "[variables('frameworkWebSite')]"
}
},
{
"name": "[concat('siteinit-', variables('frameworkWebSite'))]",
"apiVersion": "2015-05-01",
"type": "Microsoft.Insights/webtests",
"location": "Central US",
"tags": {
"displayName": "WebtestL ABL BSL Init frameworkWebSite",
"[concat('hidden-link:', resourceId('microsoft.insights/components/', variables('frameworkWebSite')))]": "Resource"
},
"dependsOn": [
"[concat('microsoft.insights/components/', variables('frameworkWebSite'))]"
],
"properties": {
"Name": "[concat('GETBytelightInit-',parameters('region'))]",
"Description": "[concat('GETBytelightInit-',parameters('region'),'.webtest')]",
"Enabled": true,
"Frequency": 600,
"Timeout": 120,
"Kind": "multistep",
"Locations": [
{ "Id": "us-il-ch1-azr" },
{ "Id": "us-ca-sjc-azr" },
{ "Id": "us-tx-sn1-azr" }
],
"Configuration": {
"WebTest": "[concat('<workingwebtest goes here>','<ends here>')]"
},
"SyntheticMonitorId": "[concat('siteinit-', variables('frameworkWebSite'))]"
}
},
{
"name": "[concat('siteinit-', variables('frameworkWebSite'), '-alert')]",
"type": "Microsoft.Insights/alertrules",
"apiVersion": "2015-04-01",
"location": "[parameters('region')]",
"tags": {
"displayName": "Alert webtest site Init frameworkWebSite",
"[concat('hidden-link:', resourceId('microsoft.insights/components/', variables('frameworkWebSite')))]": "Resource",
"[concat('hidden-link:', resourceId('microsoft.insights/webtests/', concat('siteinit-', variables('frameworkWebSite'))))]": "Resource"
},
"dependsOn": [
"[concat('microsoft.insights/components/', variables('frameworkWebSite'))]",
"[concat('microsoft.insights/webtests/siteinit-', variables('frameworkWebSite'))]"
],
"properties": {
"name": "[concat('siteinit-', variables('frameworkWebSite'), '-alert')]",
"description": "Alert for site Initialize",
"isEnabled": true,
"condition": {
"$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.LocationThresholdRuleCondition, Microsoft.WindowsAzure.Management.Mon.Client",
"odata.type": "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition",
"dataSource": {
"$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleMetricDataSource, Microsoft.WindowsAzure.Management.Mon.Client",
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri": "[resourceId('microsoft.insights/webtests/', concat('siteinit-', variables('frameworkWebSite')))]",
"metricName": "GSMT_AvRaW"
},
"windowSize": "PT15M",
"failedLocationCount": 2
},
"action": {
"$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleEmailAction, Microsoft.WindowsAzure.Management.Mon.Client",
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners": true,
"customEmails": [ ]
}
}
}
],
"outputs": {
"TestLink": {
"type": "string",
"value": "[resourceId('microsoft.insights/webtests/', concat('siteinit-', variables('frameworkWebSite')))]"
}
}
}
The deployment fails with:
"statusMessage": {
"Code": "ResourceNotFound",
"Message": "Exception of type 'Microsoft.WindowsAzure.Management.Monitoring.MonitoringServiceException' was thrown."
},
This is just the first of many test that will go in this template and each deployment has 2 copies of the site. So manual alert rule creation isn't an option.
I think there is a problem with your resourceUri:
"resourceUri": "[concat(resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('frameworkWebSite'))]",
Give it a try with the resourceId() function:
"resourceUri": "[resourceId(resourceGroup().name, 'Microsoft.Web/sites', variables('frameworkWebSite'))]",
See resourceId() reference here.
Hope this helps.