---
policy: /ce/ca/azure/sql-virtual-machine/virtual-machine-cost-effective-region
logic: /ce/ca/azure/sql-virtual-machine/virtual-machine-cost-effective-region/prod.logic.yaml
executionTime: 2025-10-01T12:47:15.176949475Z
generationMs: 61
executionMs: 916
rows:
  - id: '001'
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10Z1__disappearanceTime__c)
      actual: isDisappeared(CA10Z1__disappearanceTime__c)
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 1199
      actual: 1199
    conditionText:
      expected: extract('CA10Z1__locationName__c') == 'westeurope'
      actual: extract('CA10Z1__locationName__c') == 'westeurope'
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 2800
      actual: 2800
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/sql-virtual-machine/virtual-machine-cost-effective-region/policy.yaml
    md5Hash: 61883E93555E65C728DBC1A184F70D99
    content: |
      ---
      names:
        full: "Azure SQL Virtual Machine is located in a less cost-effective region"
        contextual: "Virtual Machine is located in a less cost-effective region"
      description: "This policy flags SQL Virtual Machines that are running in Azure regions\
        \ with higher pricing and could potentially be migrated to more cost-effective regions."
      type: "BEST_PRACTICE"
      categories:
        - "COST"
      frameworkMappings:
        - "/frameworks/cloudaware/cost-efficiency-and-optimization/resource-optimization"
  - path: /ce/ca/azure/sql-virtual-machine/virtual-machine-cost-effective-region/prod.logic.yaml
    md5Hash: C5E99582444954C3E13F23EFE2344BB8
    content: |
      ---
      inputType: "CA10Z1__CaAzureSqlVirtualMachine__c"
      importExtracts:
        - file: "/types/CA10Z1__CaAzureSqlVirtualMachine__c/object.extracts.yaml"
      testData:
        - file: 'test-data.json'
      conditions:
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in westus which is more expensive than westus3 or westus2."
          remediationMessage: "Consider migrating the VM to westus3 or westus2."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "westus"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in westcentralus which is more expensive than westus3 or westus2."
          remediationMessage: "Consider migrating the VM to westus3 or westus2."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "westcentralus"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in southcentralus which is more expensive than northcentralus, westus3 or westus2."
          remediationMessage: "Consider migrating the VM to northcentralus, westus3 or westus2."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "southcentralus"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in centralus which is more expensive than northcentralus, westus3 or westus2."
          remediationMessage: "Consider migrating the VM to northcentralus, westus3 or westus2."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "centralus"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in canadaeast which is more expensive than eastus or eastus2."
          remediationMessage: "Consider migrating the VM to eastus or eastus2."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "canadaeast"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in canadacentral which is more expensive than eastus or eastus2."
          remediationMessage: "Consider migrating the VM to eastus or eastus2."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "canadacentral"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in ukwest which is more expensive than eu-west-1, eu-north-1, or eu-south-2."
          remediationMessage: "Consider migrating the VM to eu-west-1, eu-north-1, or eu-south-2."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "ukwest"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in uksouth which is more expensive than eu-west-1, eu-north-1, or eu-south-2."
          remediationMessage: "Consider migrating the VM to eu-west-1, eu-north-1, or eu-south-2."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "uksouth"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in francecentral which is more expensive than eu-west-1, eu-north-1, or eu-south-2."
          remediationMessage: "Consider migrating the VM to eu-west-1, eu-north-1, or eu-south-2."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "francecentral"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in francesouth which is more expensive than eu-west-1, eu-north-1, or eu-south-2."
          remediationMessage: "Consider migrating the VM to eu-west-1, eu-north-1, or eu-south-2."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "francesouth"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in westeurope which is more expensive than swedencentral or northeurope."
          remediationMessage: "Consider migrating the VM to swedencentral or northeurope."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "westeurope"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in germanywestcentral which is more expensive than swedencentral or northeurope."
          remediationMessage: "Consider migrating the VM to swedencentral or northeurope."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "germanywestcentral"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in germanynorth which is more expensive than swedencentral or northeurope."
          remediationMessage: "Consider migrating the VM to swedencentral or northeurope."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "germanynorth"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in switzerlandnorth which is more expensive than swedencentral or northeurope."
          remediationMessage: "Consider migrating the VM to swedencentral or northeurope."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "switzerlandnorth"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in switzerlandwest which is more expensive than swedencentral or northeurope."
          remediationMessage: "Consider migrating the VM to swedencentral or northeurope."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "switzerlandwest"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in italynorth which is more expensive than swedencentral or northeurope."
          remediationMessage: "Consider migrating the VM to swedencentral or northeurope."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "italynorth"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in polandcentral which is more expensive than swedencentral or northeurope."
          remediationMessage: "Consider migrating the VM to swedencentral or northeurope."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "polandcentral"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in norwayeast which is more expensive than swedencentral or northeurope."
          remediationMessage: "Consider migrating the VM to swedencentral or northeurope."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "norwayeast"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in norwaywest which is more expensive than swedencentral or northeurope."
          remediationMessage: "Consider migrating the VM to swedencentral or northeurope."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "norwaywest"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in swedensouth which is more expensive than swedencentral or northeurope."
          remediationMessage: "Consider migrating the VM to swedencentral or northeurope."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "swedensouth"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in spaincentral which is more expensive than swedencentral or northeurope."
          remediationMessage: "Consider migrating the VM to swedencentral or northeurope."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "spaincentral"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in southindia which is more expensive than centralindia."
          remediationMessage: "Consider migrating the VM to centralindia."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "southindia"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in westindia which is more expensive than centralindia."
          remediationMessage: "Consider migrating the VM to centralindia."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "westindia"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in australiasoutheast which is more expensive than australiacentral, australiacentral2 or australiaeast."
          remediationMessage: "Consider migrating the VM to australiacentral, australiacentral2 or australiaeast."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "australiasoutheast"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in japaneast which is more expensive than koreasouth."
          remediationMessage: "Consider migrating the VM to koreasouth."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "japaneast"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in japanwest which is more expensive than koreasouth."
          remediationMessage: "Consider migrating the VM to koreasouth."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "japanwest"
        - status: "INCOMPLIANT"
          currentStateMessage: "The VM is running in koreacentral which is more expensive than koreasouth."
          remediationMessage: "Consider migrating the VM to koreasouth."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10Z1__locationName__c
              right:
                TEXT: "koreacentral"
      otherwise:
        status: "COMPLIANT"
        currentStateMessage: "The VM is located in a cost-effective region."
  - path: /ce/ca/azure/sql-virtual-machine/virtual-machine-cost-effective-region/test-data.json
    md5Hash: 8365CFA65B8C5155D8FD35B8FE0050CC
    content: |
      [
        {
          "expectedResult": {
            "status": "DISAPPEARED",
            "conditionIndex": "99",
            "conditionText": "isDisappeared(CA10Z1__disappearanceTime__c)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-09-24T02:10:07Z" },
          "Id": "001",
          "CA10Z1__disappearanceTime__c": "2025-09-15T05:52:54Z",
          "CA10Z1__locationName__c": "westeurope"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "1199",
            "conditionText": "extract('CA10Z1__locationName__c') == 'westeurope'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-09-24T02:10:07Z" },
          "Id": "002",
          "CA10Z1__disappearanceTime__c": null,
          "CA10Z1__locationName__c": "westeurope"
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "2800",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-09-24T02:10:07Z" },
          "Id": "003",
          "CA10Z1__disappearanceTime__c": null,
          "CA10Z1__locationName__c": "eastus"
        }
      ]
  - path: /types/CA10Z1__CaAzureSqlVirtualMachine__c/object.extracts.yaml
    md5Hash: 779778B4CC282501BCC088A9F03D60F4
    content: "---\nextracts:\n# Text\n  - name: \"CA10Z1__locationName__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10Z1__locationName__c\"\n"
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "001",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10Z1__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "1199",
      "conditionText" : "extract('CA10Z1__locationName__c') == 'westeurope'",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "2800",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10Z1__CaAzureSqlVirtualMachine__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10Z1__disappearanceTime__c TIMESTAMP,
      CA10Z1__locationName__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-09-24T02:10:07Z")
    },
    "Id" : "001",
    "CA10Z1__disappearanceTime__c" : new Date("2025-09-15T05:52:54Z"),
    "CA10Z1__locationName__c" : "westeurope"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-24T02:10:07Z")
    },
    "Id" : "002",
    "CA10Z1__locationName__c" : "westeurope"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-24T02:10:07Z")
    },
    "Id" : "003",
    "CA10Z1__locationName__c" : "eastus"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10Z1__CaAzureSqlVirtualMachine__c(
      obj STRUCT<
          Id STRING,
          CA10Z1__disappearanceTime__c TIMESTAMP,
          CA10Z1__locationName__c STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
      var TextLib = new function () {
          this.normalize = function(arg) {
              return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase();
          };
          this.isEmpty = function(arg) {
              return this.normalize(arg) == '';
          };
          this.isNotEmpty = function(arg) {
              return this.normalize(arg) != '';
          };
          this.equal = function(left, right) {
              return this.normalize(left) == this.normalize(right);
          };
          this.notEqual = function(left, right) {
              return this.normalize(left) != this.normalize(right);
          };
          this.startsWith = function(arg, substring) {
              return this.normalize(arg).startsWith(this.normalize(substring));
          };
          this.endsWith = function(arg, substring) {
              return this.normalize(arg).endsWith(this.normalize(substring));
          };
          this.contains = function(arg, substring) {
              return this.normalize(arg).includes(this.normalize(substring));
          };
          this.containsAll = function(arg, substrings) {
              if (substrings == null || substrings.length === 0) return false;
              let normalizedArg = this.normalize(arg);
              return substrings.every(sub => normalizedArg.includes(this.normalize(sub)));
          };
          this.containsAny = function(arg, substrings) {
              if (substrings == null || substrings.length === 0) return false;
              let normalizedArg = this.normalize(arg);
              return substrings.some(sub => normalizedArg.includes(this.normalize(sub)));
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From Azure [CA10Z1__disappearanceTime__c]: ' + obj.CA10Z1__disappearanceTime__c);
      if (obj.CA10Z1__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10Z1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function extract3() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      references1.push('Location Name [obj.CA10Z1__locationName__c]: ' + obj.CA10Z1__locationName__c);
      if (TextLib.equal(extract3.call(extract3), 'westus')) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10Z1__locationName__c') == 'westus'", currentStateMessage: "The VM is running in westus which is more expensive than westus3 or westus2.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to westus3 or westus2.", runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extract6() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract6.call(extract6), 'westcentralus')) {
          return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10Z1__locationName__c') == 'westcentralus'", currentStateMessage: "The VM is running in westcentralus which is more expensive than westus3 or westus2.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to westus3 or westus2.", runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      function extract9() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract9.call(extract9), 'southcentralus')) {
          return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('CA10Z1__locationName__c') == 'southcentralus'", currentStateMessage: "The VM is running in southcentralus which is more expensive than northcentralus, westus3 or westus2.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to northcentralus, westus3 or westus2.", runtimeError: null};
      }
      // condition[4], conditionIndex:[400..499]
      function extract12() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract12.call(extract12), 'centralus')) {
          return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "extract('CA10Z1__locationName__c') == 'centralus'", currentStateMessage: "The VM is running in centralus which is more expensive than northcentralus, westus3 or westus2.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to northcentralus, westus3 or westus2.", runtimeError: null};
      }
      // condition[5], conditionIndex:[500..599]
      function extract15() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract15.call(extract15), 'canadaeast')) {
          return {status: 'INCOMPLIANT', conditionIndex: 599, conditionText: "extract('CA10Z1__locationName__c') == 'canadaeast'", currentStateMessage: "The VM is running in canadaeast which is more expensive than eastus or eastus2.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to eastus or eastus2.", runtimeError: null};
      }
      // condition[6], conditionIndex:[600..699]
      function extract18() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract18.call(extract18), 'canadacentral')) {
          return {status: 'INCOMPLIANT', conditionIndex: 699, conditionText: "extract('CA10Z1__locationName__c') == 'canadacentral'", currentStateMessage: "The VM is running in canadacentral which is more expensive than eastus or eastus2.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to eastus or eastus2.", runtimeError: null};
      }
      // condition[7], conditionIndex:[700..799]
      function extract21() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract21.call(extract21), 'ukwest')) {
          return {status: 'INCOMPLIANT', conditionIndex: 799, conditionText: "extract('CA10Z1__locationName__c') == 'ukwest'", currentStateMessage: "The VM is running in ukwest which is more expensive than eu-west-1, eu-north-1, or eu-south-2.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to eu-west-1, eu-north-1, or eu-south-2.", runtimeError: null};
      }
      // condition[8], conditionIndex:[800..899]
      function extract24() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract24.call(extract24), 'uksouth')) {
          return {status: 'INCOMPLIANT', conditionIndex: 899, conditionText: "extract('CA10Z1__locationName__c') == 'uksouth'", currentStateMessage: "The VM is running in uksouth which is more expensive than eu-west-1, eu-north-1, or eu-south-2.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to eu-west-1, eu-north-1, or eu-south-2.", runtimeError: null};
      }
      // condition[9], conditionIndex:[900..999]
      function extract27() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract27.call(extract27), 'francecentral')) {
          return {status: 'INCOMPLIANT', conditionIndex: 999, conditionText: "extract('CA10Z1__locationName__c') == 'francecentral'", currentStateMessage: "The VM is running in francecentral which is more expensive than eu-west-1, eu-north-1, or eu-south-2.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to eu-west-1, eu-north-1, or eu-south-2.", runtimeError: null};
      }
      // condition[10], conditionIndex:[1000..1099]
      function extract30() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract30.call(extract30), 'francesouth')) {
          return {status: 'INCOMPLIANT', conditionIndex: 1099, conditionText: "extract('CA10Z1__locationName__c') == 'francesouth'", currentStateMessage: "The VM is running in francesouth which is more expensive than eu-west-1, eu-north-1, or eu-south-2.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to eu-west-1, eu-north-1, or eu-south-2.", runtimeError: null};
      }
      // condition[11], conditionIndex:[1100..1199]
      function extract33() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract33.call(extract33), 'westeurope')) {
          return {status: 'INCOMPLIANT', conditionIndex: 1199, conditionText: "extract('CA10Z1__locationName__c') == 'westeurope'", currentStateMessage: "The VM is running in westeurope which is more expensive than swedencentral or northeurope.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to swedencentral or northeurope.", runtimeError: null};
      }
      // condition[12], conditionIndex:[1200..1299]
      function extract36() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract36.call(extract36), 'germanywestcentral')) {
          return {status: 'INCOMPLIANT', conditionIndex: 1299, conditionText: "extract('CA10Z1__locationName__c') == 'germanywestcentral'", currentStateMessage: "The VM is running in germanywestcentral which is more expensive than swedencentral or northeurope.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to swedencentral or northeurope.", runtimeError: null};
      }
      // condition[13], conditionIndex:[1300..1399]
      function extract39() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract39.call(extract39), 'germanynorth')) {
          return {status: 'INCOMPLIANT', conditionIndex: 1399, conditionText: "extract('CA10Z1__locationName__c') == 'germanynorth'", currentStateMessage: "The VM is running in germanynorth which is more expensive than swedencentral or northeurope.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to swedencentral or northeurope.", runtimeError: null};
      }
      // condition[14], conditionIndex:[1400..1499]
      function extract42() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract42.call(extract42), 'switzerlandnorth')) {
          return {status: 'INCOMPLIANT', conditionIndex: 1499, conditionText: "extract('CA10Z1__locationName__c') == 'switzerlandnorth'", currentStateMessage: "The VM is running in switzerlandnorth which is more expensive than swedencentral or northeurope.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to swedencentral or northeurope.", runtimeError: null};
      }
      // condition[15], conditionIndex:[1500..1599]
      function extract45() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract45.call(extract45), 'switzerlandwest')) {
          return {status: 'INCOMPLIANT', conditionIndex: 1599, conditionText: "extract('CA10Z1__locationName__c') == 'switzerlandwest'", currentStateMessage: "The VM is running in switzerlandwest which is more expensive than swedencentral or northeurope.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to swedencentral or northeurope.", runtimeError: null};
      }
      // condition[16], conditionIndex:[1600..1699]
      function extract48() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract48.call(extract48), 'italynorth')) {
          return {status: 'INCOMPLIANT', conditionIndex: 1699, conditionText: "extract('CA10Z1__locationName__c') == 'italynorth'", currentStateMessage: "The VM is running in italynorth which is more expensive than swedencentral or northeurope.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to swedencentral or northeurope.", runtimeError: null};
      }
      // condition[17], conditionIndex:[1700..1799]
      function extract51() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract51.call(extract51), 'polandcentral')) {
          return {status: 'INCOMPLIANT', conditionIndex: 1799, conditionText: "extract('CA10Z1__locationName__c') == 'polandcentral'", currentStateMessage: "The VM is running in polandcentral which is more expensive than swedencentral or northeurope.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to swedencentral or northeurope.", runtimeError: null};
      }
      // condition[18], conditionIndex:[1800..1899]
      function extract54() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract54.call(extract54), 'norwayeast')) {
          return {status: 'INCOMPLIANT', conditionIndex: 1899, conditionText: "extract('CA10Z1__locationName__c') == 'norwayeast'", currentStateMessage: "The VM is running in norwayeast which is more expensive than swedencentral or northeurope.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to swedencentral or northeurope.", runtimeError: null};
      }
      // condition[19], conditionIndex:[1900..1999]
      function extract57() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract57.call(extract57), 'norwaywest')) {
          return {status: 'INCOMPLIANT', conditionIndex: 1999, conditionText: "extract('CA10Z1__locationName__c') == 'norwaywest'", currentStateMessage: "The VM is running in norwaywest which is more expensive than swedencentral or northeurope.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to swedencentral or northeurope.", runtimeError: null};
      }
      // condition[20], conditionIndex:[2000..2099]
      function extract60() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract60.call(extract60), 'swedensouth')) {
          return {status: 'INCOMPLIANT', conditionIndex: 2099, conditionText: "extract('CA10Z1__locationName__c') == 'swedensouth'", currentStateMessage: "The VM is running in swedensouth which is more expensive than swedencentral or northeurope.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to swedencentral or northeurope.", runtimeError: null};
      }
      // condition[21], conditionIndex:[2100..2199]
      function extract63() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract63.call(extract63), 'spaincentral')) {
          return {status: 'INCOMPLIANT', conditionIndex: 2199, conditionText: "extract('CA10Z1__locationName__c') == 'spaincentral'", currentStateMessage: "The VM is running in spaincentral which is more expensive than swedencentral or northeurope.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to swedencentral or northeurope.", runtimeError: null};
      }
      // condition[22], conditionIndex:[2200..2299]
      function extract66() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract66.call(extract66), 'southindia')) {
          return {status: 'INCOMPLIANT', conditionIndex: 2299, conditionText: "extract('CA10Z1__locationName__c') == 'southindia'", currentStateMessage: "The VM is running in southindia which is more expensive than centralindia.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to centralindia.", runtimeError: null};
      }
      // condition[23], conditionIndex:[2300..2399]
      function extract69() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract69.call(extract69), 'westindia')) {
          return {status: 'INCOMPLIANT', conditionIndex: 2399, conditionText: "extract('CA10Z1__locationName__c') == 'westindia'", currentStateMessage: "The VM is running in westindia which is more expensive than centralindia.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to centralindia.", runtimeError: null};
      }
      // condition[24], conditionIndex:[2400..2499]
      function extract72() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract72.call(extract72), 'australiasoutheast')) {
          return {status: 'INCOMPLIANT', conditionIndex: 2499, conditionText: "extract('CA10Z1__locationName__c') == 'australiasoutheast'", currentStateMessage: "The VM is running in australiasoutheast which is more expensive than australiacentral, australiacentral2 or australiaeast.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to australiacentral, australiacentral2 or australiaeast.", runtimeError: null};
      }
      // condition[25], conditionIndex:[2500..2599]
      function extract75() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract75.call(extract75), 'japaneast')) {
          return {status: 'INCOMPLIANT', conditionIndex: 2599, conditionText: "extract('CA10Z1__locationName__c') == 'japaneast'", currentStateMessage: "The VM is running in japaneast which is more expensive than koreasouth.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to koreasouth.", runtimeError: null};
      }
      // condition[26], conditionIndex:[2600..2699]
      function extract78() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract78.call(extract78), 'japanwest')) {
          return {status: 'INCOMPLIANT', conditionIndex: 2699, conditionText: "extract('CA10Z1__locationName__c') == 'japanwest'", currentStateMessage: "The VM is running in japanwest which is more expensive than koreasouth.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to koreasouth.", runtimeError: null};
      }
      // condition[27], conditionIndex:[2700..2799]
      function extract81() { if (!this.out) { this.out = obj.CA10Z1__locationName__c; } return this.out; };
      if (TextLib.equal(extract81.call(extract81), 'koreacentral')) {
          return {status: 'INCOMPLIANT', conditionIndex: 2799, conditionText: "extract('CA10Z1__locationName__c') == 'koreacentral'", currentStateMessage: "The VM is running in koreacentral which is more expensive than koreasouth.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating the VM to koreasouth.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 2800, conditionText: "otherwise", currentStateMessage: "The VM is located in a cost-effective region.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;


  SELECT
    expectedResult.Id as Id,
    IF (
      IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '')
      AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1)
      AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '')
      AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''),
      "MATCH",
      "FAIL"
    ) as match,
    expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus,
    expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex,
    expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText,
    expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError
  FROM UNNEST(mock_ExpectedResult()) expectedResult
  LEFT JOIN (
      SELECT
          sObject.Id AS Id,
          sObject.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c,
          sObject.CA10Z1__locationName__c AS CA10Z1__locationName__c,
          process_CA10Z1__CaAzureSqlVirtualMachine__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c,
                  sObject.CA10Z1__locationName__c AS CA10Z1__locationName__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10Z1__CaAzureSqlVirtualMachine__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
