Package: azureenergylabelercli
A cli to help generate energy label for Azure tenant, subscriptions and resource groups.Documentation:https://azureenergylabelercli.readthedocs.org/en/latestEnergy LabelsEnergy Labels tablelabelhighmediumlowA =>0up to 10up to 20B ==>up to 10up to 20up to 40C ===>up to 15up to 30up to 60D ====>up to 20up to 40up to 80E =====>up to 25up to 50up to 100ArgumentsCLI Arguments tabledescriptionCLI argumentenvironment variableexample valueTenant ID (required)–tenant-idAZURE_LABELER_TENANT_ID00000000-0000-0000-0000-000000000000Path to export the results–export-pathAZURE_LABELER_EXPORT_PATH/local/pathor Storage Account Url with SAS tokenhttps://sa.blob.windows.net/container/?sas_tokenExport only number of findings and energy label–export-metricsAZURE_LABELER_EXPORT_METRICSfalse(default)Export all findings information along with energy label–export-allAZURE_LABELER_EXPORT_ALLtrue(default)Regulatory frameworks to take into account–frameworksAZURE_LABELER_FRAMEWORKS‘Microsoft cloud security benchmark,Azure CIS 1.1.0’Explicit list of subscriptions to take into account–allowed-subscription-idsAZURE_LABELER_ALLOWED_SUBSCRIPTION_IDS‘00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000001’Explicit list of subscriptions NOT to take into account–denied-subscription-idsAZURE_LABELER_DENIED_SUBSCRIPTION_IDS‘00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000001’List of resource groups to exclude–denied-resource-group-namesAZURE_LABELER_DENIED_RESOURCE_GROUP_NAMES‘SBPP-WEU-AARC-01-RSG, SBPA-WEU-AARC-01-RSG’Level of log printing–log-levelAZURE_LABELER_LOG_LEVELinfoLogging configuration–log-configAZURE_LABELER_LOG_CONFIGSupported authentication typesAzure CLIIf you are running the Energy Labeler from your local machine, make sure the user you are authenticated as has theSecurity Readerpermission or higher.azlogin--tenant00000000-0000-0000-0000-000000000000Managed IdentityIf you are running theazureenergylabelercontainer in Azure (on ACI, ACA, etc), this is safest and preferred authentication method.
To make use of Managed Identity authentication for the Energy Labeler, make sure it is enabled on your instance (ACI, Function App, etc):
.. code-block:identity: {
    type: 'SystemAssigned'

}Also make sure you have a role assignment to your instance,Security Readeris required.
.. code-block:@description('Security Reader role definition')
var roleDefinitionId = resourceId('microsoft.authorization/roleDefinitions', '39bc4728-0917-49c7-9d2c-d95423bc2eb4')

@description('Assign Security Reader role to the container so it can gather security compliance of the subscription/tenant')
resource securityReaderAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
  name: guid(name)
  scope: tenant()
  properties: {
    principalId: containergroup.identity.principalId
    roleDefinitionId: roleDefinitionId
  }
}Service Principal credentialsIf you are running theazureenergylabelercontainer outside Azure, you need to authenticate to Azure using Service Principal credentials.
The Service Principal therefore must haveSecurity Readerpermission assigned to either at Tenant Level or to the subscriptions where Energy Label are calculated.Service principal with secretCLI Arguments tablevariable namevalueAZURE_CLIENT_IDid of an Azure Active Directory applicationAZURE_TENANT_IDid of the application’s Azure Active Directory tenantAZURE_CLIENT_SECRETone of the application’s client secretsService principal with certificateCLI Arguments tablevariable namevalueAZURE_CLIENT_IDid of an Azure Active Directory applicationAZURE_TENANT_IDid of the application’s Azure Active Directory tenantAZURE_CLIENT_CERTIFICATE_PATHpath to a PEM or PKCS12 certificate file including private keyAZURE_CLIENT_CERTIFICATE_PASSWORDpassword of the certificate file, if anyInstallationPipxpipx install azureenergylabelercli
  installed package azureenergylabelercli 1.0.0, installed using Python 3.10.5
  These apps are now globally available
    - azure-energy-labeler
    - azure_energy_labeler_cli.py
done! ✨ 🌟 ✨ExamplesCalculate energy label for a tenantazure-energy-labeler --tenant-id <TENANT_ID>Calculate energy label for two subscriptions in a tenantazure-energy-labeler --tenant-id <TENANT_ID> --allowed-subscription-ids 00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000001Calculate energy label for a tenant and export all findings to a local folderazure-energy-labeler --tenant-id 2ba489e8-3466-4f52-a32d-263d28b832e1 --export-path /tmp/ --export-allCalculate energy label for a tenant and export all findings to a Storage Account Blob Containerazure-energy-labeler --tenant-id 2ba489e8-3466-4f52-a32d-263d28b832e1 --export-path "https://sa.blob.windows.net/container/?sas_token" --export-allDevelopment WorkflowThe workflow supports the following stepslinttestbuilddocumentuploadgraphThese actions are supported out of the box by the corresponding scripts under _CI/scripts directory with sane defaults based on best practices.
Sourcing setup_aliases.ps1 for windows powershell or setup_aliases.sh in bash on Mac or Linux will provide with handy aliases for the shell of all those commands prepended with an underscore.The bootstrap script creates a .venv directory inside the project directory hosting the virtual environment. It uses pipenv for that.
It is called by all other scripts before they do anything. So one could simple start by calling _lint and that would set up everything before it tried to actually lint the projectOnce the code is ready to be delivered the _tag script should be called accepting one of three arguments, patch, minor, major following the semantic versioning scheme.
So for the initial delivery one would call$ _tag –minorwhich would bump the version of the project to 0.1.0 tag it in git and do a push and also ask for the change and automagically update HISTORY.rst with the version and the change provided.So the full workflow after git is initialized is:repeat as necessary (of course it could be test - code - lint :) )codelinttestcommit and pushdevelop more through the code-lint-test cycletag (with the appropriate argument)buildupload (if you want to host your package in pypi)document (of course this could be run at any point)Important InformationThis template is based on pipenv. In order to be compatible with requirements.txt so the actual created package can be used by any part of the existing python ecosystem some hacks were needed.
So when building a package out of thisdo notsimple call$ python setup.py sdist bdist_eggas this will produce an unusable artifact with files missing.Instead use the provided build and upload scripts that create all the necessary files in the artifact.Project FeaturesTODOHistory0.0.1 (04-05-2022)First code creation0.1.0 (27-06-2022)First release1.0.0 (22-09-2022)Add support for environment variables as default argument valueArguments with array of values changed from a space separated list to a comma separated listCLI now uses the most recent version of the azureenergylabelerlib1.0.1 (26-09-2022)Fixed a bug preventing collection of resource group findings1.1.0 (04-10-2022)Updated dependency azurenergylabelerlib to version 2.0.02.0.0 (19-10-2022)Microsoft renamed “Azure Security Benchmark” to “Microsoft cloud security benchmark”, changing the interface2.0.1 (20-10-2022)Fix broken dependecies2.0.2 (08-03-2023)Bump template and dependencies.2.0.3 (21-03-2023)Bumped library version which now filters subscriptions based on the tenant_id.2.1.0 (15-05-2023)Added option to disable banner and spinnerImproved filtering of findings2.1.1 (28-06-2023)Updated library dependency2.2.0 (22-09-2023)feat: updating azureenergylabelerlib to 3.3.0 to allow excluding resource groups2.2.1 (22-09-2023)Fix: AZURE_LABELER_DENIED_RESOURCE_GROUP_NAMES changed to a string delimited list due to gitlab-ci not supporting variables of the type list.2.2.2 (22-09-2023)fix: the list syntax in the readme file broke the release. It expects a comma after a quote.2.2.3 (22-09-2023)fix: the list syntax in the readme file broke the release. It expects a comma after a quote.2.2.4 (03-10-2023)fix: denied_resource_group_names was optional in azureenergylabelerlib 3.3.0. This broke the code if no value was given, therefore updating to 3.3.1.2.2.5 (05-10-2023)feat: added validation for azure resource group names in azureenergylaberlib 3.3.2