--- policy: /ce/ca/azure/app-service/plan-without-apps logic: /ce/ca/azure/app-service/plan-without-apps/prod.logic.yaml executionTime: 2026-06-06T12:03:31.761902957Z generationMs: 51 executionMs: 875 rows: - id: test1 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10__numberOfSites__c') == number(0.0) actual: extract('CA10__numberOfSites__c') == number(0.0) runtimeError: {} - id: test2 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10__numberOfSites__c').isEmpty() actual: extract('CA10__numberOfSites__c').isEmpty() runtimeError: {} - id: test3 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 300 actual: 300 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/azure/app-service/plan-without-apps/policy.yaml md5Hash: B5E3D0CADC5068FE264A0B4C7A23D49D content: | --- names: full: "Azure App Service Plan has no Apps assigned" contextual: "App Service Plan has no Apps assigned" description: "Ensure that Azure App Service Plan has at least one attached Azure App.\ \ Consider deleting App Service Plans that are empty and have no applications,\ \ sites or jobs associated with them." categories: - "COST" type: "COMPLIANCE_POLICY" frameworkMappings: - "/frameworks/cloudaware/cost-efficiency-and-optimization/waste-reduction" - path: /ce/ca/azure/app-service/plan-without-apps/prod.logic.yaml md5Hash: 808879315748BEF90402AF75AFAEBB82 content: | --- inputType: "CA10__CaAzureAppServicePlan__c" testData: - file: test-data.json importExtracts: - file: /types/CA10__CaAzureAppServicePlan__c/object.extracts.yaml conditions: - status: "INCOMPLIANT" currentStateMessage: "The Azure App Service plan has no apps assigned." remediationMessage: "Delete the empty App Service plan." check: IS_EMPTY: arg: EXTRACT: "CA10__numberOfSites__c" - status: "INCOMPLIANT" currentStateMessage: "The Azure App Service plan has no apps assigned." remediationMessage: "Delete the empty App Service plan." check: IS_EQUAL: left: EXTRACT: "CA10__numberOfSites__c" right: NUMBER: 0.0 otherwise: status: "COMPLIANT" currentStateMessage: "The Azure App Service plan has apps assigned." - path: /ce/ca/azure/app-service/plan-without-apps/test-data.json md5Hash: 2CD0BC829C66590E4352D747382FD188 content: | [ { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "299", "conditionText": "extract('CA10__numberOfSites__c') == number(0.0)", "runtimeError": null }, "context": { "snapshotTime": "2025-03-27T10:40:33Z" }, "Id": "test1", "CA10__disappearanceTime__c": null, "CA10__numberOfSites__c": 0 }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "199", "conditionText": "extract('CA10__numberOfSites__c').isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2025-03-27T10:40:33Z" }, "Id": "test2", "CA10__disappearanceTime__c": null, "CA10__numberOfSites__c": null }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "300", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2025-03-27T10:40:33Z" }, "Id": "test3", "CA10__disappearanceTime__c": null, "CA10__numberOfSites__c": 1 } ] - path: /types/CA10__CaAzureAppServicePlan__c/object.extracts.yaml md5Hash: 874C85D079713FFDDFD45E8EC52BC0A5 content: "---\nextracts:\n# Nullable.\n - name: \"CA10__numberOfSites__c\"\n\ \ value: \n FIELD:\n path: \"CA10__numberOfSites__c\"\n" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test1", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "299", "conditionText" : "extract('CA10__numberOfSites__c') == number(0.0)", "runtimeError" : null } }, { "Id" : "test2", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "199", "conditionText" : "extract('CA10__numberOfSites__c').isEmpty()", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "300", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAzureAppServicePlan__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-03-27T10:40:33Z") }, "CA10__numberOfSites__c" : 0, "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2025-03-27T10:40:33Z") }, "CA10__numberOfSites__c" : null, "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2025-03-27T10:40:33Z") }, "CA10__numberOfSites__c" : 1, "Id" : "test3" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAzureAppServicePlan__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__numberOfSites__c FLOAT64, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var IsEmptyLib = new function () { this.simpleIsEmpty = function(arg) { return arg == null; }; this.simpleIsNotEmpty = function(arg) { return arg != null; }; }(); var references1 = []; // condition[0], conditionIndex:[0..99] references1.push('Deleted From Azure [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c); if (obj.CA10__disappearanceTime__c != null) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__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.CA10__numberOfSites__c; } return this.out; }; references1.push('Number Of Sites [obj.CA10__numberOfSites__c]: ' + obj.CA10__numberOfSites__c); if (IsEmptyLib.simpleIsEmpty(extract3.call(extract3))) { return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__numberOfSites__c').isEmpty()", currentStateMessage: "The Azure App Service plan has no apps assigned.", currentStateReferences: references1.join('\n'), remediation: "Delete the empty App Service plan.", runtimeError: null}; } // condition[2], conditionIndex:[200..299] function extract6() { if (!this.out) { this.out = obj.CA10__numberOfSites__c; } return this.out; }; if (extract6.call(extract6) == 0.0) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__numberOfSites__c') == number(0.0)", currentStateMessage: "The Azure App Service plan has no apps assigned.", currentStateReferences: references1.join('\n'), remediation: "Delete the empty App Service plan.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "The Azure App Service plan has apps assigned.", 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.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__numberOfSites__c AS CA10__numberOfSites__c, sObject.Id AS Id, process_CA10__CaAzureAppServicePlan__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__numberOfSites__c AS CA10__numberOfSites__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAzureAppServicePlan__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;