diff --git a/docs/_automation/powershell/cost/Get-FinOpsCostExport.md b/docs/_automation/powershell/cost/Get-FinOpsCostExport.md index d8bd93910..4bade18ca 100644 --- a/docs/_automation/powershell/cost/Get-FinOpsCostExport.md +++ b/docs/_automation/powershell/cost/Get-FinOpsCostExport.md @@ -3,8 +3,8 @@ layout: default grand_parent: PowerShell parent: Cost Management title: Get-FinOpsCostExport -nav_order: 1 -description: 'Get a list of Cost Management exports.' +nav_order: 10 +description: Get a list of Cost Management exports. permalink: /powershell/cost/Get-FinOpsCostExport --- @@ -42,28 +42,30 @@ This command has been tested with the following API versions: ```powershell Get-FinOpsCostExport ` - [-Name ] ` - [-Scope ] ` - [-DataSet ] ` - [-StorageAccountId ] ` - [-StorageContainer ] ` - [-RunHistory] ` - [-ApiVersion ] + [[‑Name] ] ` + [‑Scope ] ` + [‑Dataset ] ` + [‑DatasetVersion ] ` + [‑StorageAccountId ] ` + [‑StorageContainer ] ` + [‑RunHistory] ` + [‑ApiVersion ] ```
## 📥 Parameters -| Name | Description | -| ------------------- | ------------------------------------------------------------------------------------------------------------------- | -| `‑Name` | Optional. Name of the export. Supports wildcards. | -| `‑Scope` | Optional. Resource ID of the scope the export was created for. If empty, defaults to current subscription context. | -| `‑DataSet` | Optional. Dataset to get exports for. Allowed values = "ActualCost", "AmortizedCost". Default = null (all exports). | -| `‑StorageAccountId` | Optional. Resource ID of the storage account to get exports for. Default = null (all exports). | -| `‑StorageContainer` | Optional. Name of the container to get exports for. Supports wildcards. Default = null (all exports). | -| `‑RunHistory` | Optional. Indicates whether the run history should be expanded. Default = false. | -| `‑ApiVersion` | Optional. API version to use when calling the Cost Management exports API. Default = 2023-07-01-preview. | +| Name | Description | +| ---- | ----------- | +| `‑Name` | Optional. Name of the export. Supports wildcards. | +| `‑Scope` | Optional. Resource ID of the scope the export was created for. If empty, defaults to current subscription context. | +| `‑Dataset` | Optional. Dataset to export. Allowed values = "ActualCost", "AmortizedCost", "FocusCost", "PriceSheet", "ReservationDetails", "ReservationTransactions", "ReservationRecommendations". Default = null (all exports). | +| `‑DatasetVersion` | Optional. Schema version of the dataset to export. Default = null (all exports). | +| `‑StorageAccountId` | Optional. Resource ID of the storage account to get exports for. Default = null (all exports). | +| `‑StorageContainer` | Optional. Name of the container to get exports for. Supports wildcards. Default = null (all exports). | +| `‑RunHistory` | Optional. Indicates whether the run history should be expanded. Default = false. | +| `‑ApiVersion` | Optional. API version to use when calling the Cost Management exports API. Default = 2023-07-01-preview. |
@@ -71,35 +73,35 @@ Get-FinOpsCostExport ` ### FinOpsCostExport object -| Property | Type | JSON path | -| --------------------- | ---------------------------- | ---------------------------------------------------------------------------- | -| `Name` | String | `name` | -| `Id` | String | `id` | -| `Type` | String | `type` | -| `eTag` | String | `eTag` | -| `Description` | String | `properties.exportDescription` | -| `Dataset` | String | `properties.definition.type` | -| `DatasetVersion` | String | `properties.definition.configuration.dataVersion` | -| `DatasetFilters` | String | `properties.definition.configuration.filter` | -| `DatasetTimeFrame` | String | `properties.definition.timeframe` | -| `DatasetStartDate` | DateTime | `properties.definition.timePeriod.from` | -| `DatasetEndDate` | DateTime | `properties.definition.timePeriod.to` | -| `DatasetGranularity` | String | `properties.definition.dataset.granularity` | -| `ScheduleStatus` | String | `properties.schedule.status` | -| `ScheduleRecurrence` | String | `properties.schedule.recurrence` | -| `ScheduleStartDate` | DateTime | `properties.schedule.recurrencePeriod.from` | -| `ScheduleEndDate` | DateTime | `properties.schedule.recurrencePeriod.to` | -| `NextRuntimeEstimate` | DateTime | `properties.nextRunTimeEstimate` | -| `Format` | String | `properties.format` | -| `StorageAccountId` | String | `properties.deliveryInfo.destination.resourceId` | -| `StorageContainer` | String | `properties.deliveryInfo.destination.container` | -| `StoragePath` | String | `properties.deliveryInfo.destination.rootfolderpath` | -| `OverwriteData` | Boolean | `properties.deliveryInfo.dataOverwriteBehavior` == "OverwritePreviousReport" | -| `PartitionData` | Boolean | `properties.deliveryInfo.partitionData` | -| `CompressionMode` | String | `properties.deliveryInfo.compressionMode` | -| `RunHistory` | FinOpsCostExportRunHistory[] | `properties.runHistory.value` | - -### FinOpsCostExportRunHistory object +| Property | Type | JSON path | +| --------------------- | --------------------- | ---------------------------------------------------------------------------- | +| `Name` | String | `name` | +| `Id` | String | `id` | +| `Type` | String | `type` | +| `eTag` | String | `eTag` | +| `Description` | String | `properties.exportDescription` | +| `Dataset` | String | `properties.definition.type` | +| `DatasetVersion` | String | `properties.definition.configuration.dataVersion` | +| `DatasetFilters` | String | `properties.definition.configuration.filter` | +| `DatasetTimeFrame` | String | `properties.definition.timeframe` | +| `DatasetStartDate` | DateTime | `properties.definition.timePeriod.from` | +| `DatasetEndDate` | DateTime | `properties.definition.timePeriod.to` | +| `DatasetGranularity` | String | `properties.definition.dataset.granularity` | +| `ScheduleStatus` | String | `properties.schedule.status` | +| `ScheduleRecurrence` | String | `properties.schedule.recurrence` | +| `ScheduleStartDate` | DateTime | `properties.schedule.recurrencePeriod.from` | +| `ScheduleEndDate` | DateTime | `properties.schedule.recurrencePeriod.to` | +| `NextRuntimeEstimate` | DateTime | `properties.nextRunTimeEstimate` | +| `Format` | String | `properties.format` | +| `StorageAccountId` | String | `properties.deliveryInfo.destination.resourceId` | +| `StorageContainer` | String | `properties.deliveryInfo.destination.container` | +| `StoragePath` | String | `properties.deliveryInfo.destination.rootfolderpath` | +| `OverwriteData` | Boolean | `properties.deliveryInfo.dataOverwriteBehavior` == "OverwritePreviousReport" | +| `PartitionData` | Boolean | `properties.deliveryInfo.partitionData` | +| `CompressionMode` | String | `properties.deliveryInfo.compressionMode` | +| `RunHistory` | FinOpsCostExportRun[] | `properties.runHistory.value` | + +### FinOpsCostExportRun object | Property | Type | JSON path | | --------------- | -------- | -------------------------------------------------------- | @@ -116,7 +118,7 @@ Get-FinOpsCostExport ` ## 🌟 Examples -### Get all cost exports for a subscription +### Get cost exports for a subscription ```powershell Get-FinOpsCostExport ` @@ -133,28 +135,28 @@ Get-FinOpsCostExport ` -Scope "providers/Microsoft.Billing/billingAccounts/00000000" ``` -Gets export with name matching wildcard mtd\* within the specified billing account scope. Does not include exports in nested resource groups. +Gets export with name matching wildcard mtd* within the specified billing account scope. Does not include exports in nested resource groups. -### Get all amortized cost exports +### Get amortized cost exports ```powershell Get-FinOpsCostExport ` - -DataSet "AmortizedCost" + -Dataset "AmortizedCost" ``` Gets all exports within the current context subscription scope and filtered by dataset AmortizedCost. -### Get exports using a specific storage account +### Get exports using a storage account ```powershell Get-FinOpsCostExport ` - -Scope "/subscriptions/00000000-0000-0000-0000-000000000000"` + -Scope "/subscriptions/00000000-0000-0000-0000-000000000000" ` -StorageAccountId "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Storage/storageAccounts/MyStorageAccount" ``` Gets all exports within the subscription scope filtered by a specific storage account. -### Get exports using a specific container +### Get exports using a storage container ```powershell Get-FinOpsCostExport ` @@ -164,23 +166,24 @@ Get-FinOpsCostExport ` Gets all exports within the subscription scope for a specific container. Supports wildcard. -### Get exports using a specific API version +### Get exports using an API version ```powershell Get-FinOpsCostExport ` - -Scope "/subscriptions/00000000-0000-0000-0000-000000000000" - -StorageContainer "mtd*" - -ApiVersion "2023-08-01" - -StorageContainer "MyContainer*" + -Scope "/subscriptions/00000000-0000-0000-0000-000000000000" ` + -StorageContainer "mtd*" ` + -ApiVersion "2023-07-01-preview" ``` Gets all exports within the subscription scope for a container matching wildcard pattern and using a specific API version. +
--- ## 🧰 Related tools -{% include tools.md hubs="1" pbi="1" %} +{% include tools.md aoe="1" bicep="0" data="0" hubs="1" pbi="1" ps="0" %}
+ diff --git a/docs/_automation/powershell/cost/New-FinOpsCostExport.md b/docs/_automation/powershell/cost/New-FinOpsCostExport.md index 150eff5ff..2ba09739b 100644 --- a/docs/_automation/powershell/cost/New-FinOpsCostExport.md +++ b/docs/_automation/powershell/cost/New-FinOpsCostExport.md @@ -3,8 +3,8 @@ layout: default grand_parent: PowerShell parent: Cost Management title: New-FinOpsCostExport -nav_order: 1 -description: 'Creates a new Cost Management export.' +nav_order: 10 +description: Creates a new Cost Management export. permalink: /powershell/cost/New-FinOpsCostExport --- @@ -30,7 +30,6 @@ Creates a new Cost Management export. The **New-FinOpsCostExport** command creates a new Cost Management export for the specified scope. This command has been tested with the following API versions: - - 2023-07-01-preview (default) – Enables FocusCost and other datasets. - 2023-08-01 @@ -41,70 +40,70 @@ This command has been tested with the following API versions: ```powershell # Create a new daily/monthly export New-FinOpsCostExport ` - [-Name] ` - -Scope ` - [-Dataset ] ` - [-DatasetVersion ] ` - [-DatasetFilters ] ` - [-Monthly] ` - [-StartDate ] ` - [-EndDate ] ` - -StorageAccountId ` - [-StorageContainer ] ` - [-StoragePath ] ` - [-Location] ` - [-DoNotPartition] ` - [-DoNotOverwrite] ` - [-Execute] ` - [-Backfill ] ` - [-ApiVersion ] + [‑Name] ` + [[‑Scope] ] ` + [‑Dataset ] ` + [‑DatasetVersion ] ` + [‑DatasetFilters ] ` + [‑Monthly] ` + [‑StartDate ] ` + [‑EndDate ] ` + ‑StorageAccountId ` + [‑StorageContainer ] ` + [‑StoragePath ] ` + [‑Location ] ` + [‑DoNotPartition] ` + [‑DoNotOverwrite] ` + [‑Execute] ` + [‑Backfill ] ` + [‑ApiVersion ] ``` ```powershell # Create a new one-time export New-FinOpsCostExport ` - [-Name] ` - -Scope ` - [-Dataset ] ` - [-DatasetVersion ] ` - [-DatasetFilters ] ` - -OneTime ` - -StartDate ` - -EndDate ` - -StorageAccountId ` - [-StorageContainer ] ` - [-StoragePath ] ` - [-Location] ` - [-DoNotPartition] ` - [-ApiVersion ] + [‑Name] ` + [[‑Scope] ] ` + [‑Dataset ] ` + [‑DatasetVersion ] ` + [‑DatasetFilters ] ` + [‑OneTime] ` + [‑StartDate ] ` + [‑EndDate ] ` + ‑StorageAccountId ` + [‑StorageContainer ] ` + [‑StoragePath ] ` + [‑Location ] ` + [‑DoNotPartition] ` + [‑DoNotOverwrite] ` + [‑Execute] ` + [‑ApiVersion ] ```
## 📥 Parameters -| Name | Description | -| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `‑Name` | Required. Name of the export. | -| `‑Scope` | Required. Resource ID of the scope to export data for. | -| `‑Dataset` | Optional. Dataset to export. Allowed values = "ActualCost", "AmortizedCost". Default = "ActualCost". | -| `‑DatasetVersion` | Optional. Schema version of the dataset to export. Default = (latest version as of June 2024; e.g., "1.0" for FocusCost). | -| `‑DatasetFilters` | Optional. Dictionary of key/value pairs to filter the dataset with. Only applies to ReservationRecommendations dataset in 2023-07-01-preview. Valid filters are reservationScope (Shared or Single), resourceType (e.g., VirtualMachines), lookBackPeriod (Last7Days, Last30Days, Last60Days). | -| `‑Monthly` | Optional. Indicates that the export should be executed monthly (instead of daily). Default = false. | -| `‑OneTime` | Optional. Indicates that the export should only be executed once. When set, the start/end dates are the dates to query data for. Cannot be used in conjunction with the -Monthly option. | -| `‑StartDate` | Optional. Day to start running exports. Default = First day of the previous month if -OneTime is set; otherwise, tomorrow (DateTime.Now.AddDays(1)). | -| `‑EndDate` | Optional. Last day to run the export. Default = Last day of the month identified in -StartDate if -OneTime is set; otherwise, 5 years from -StartDate. | -| `‑StorageAccountId` | Required. Resource ID of the storage account to export data to. | -| `‑StorageContainer` | Optional. Name of the container to export data to. Container is created if it doesn't exist. Default = "cost-management". | -| `‑StoragePath` | Optional. Path to export data to within the storage container. Default = (scope ID). | -| `‑Location` | Optional. Indicates the Azure location to use for the managed identity used to push data to the storage account. Managed identity is required in order to work with storage accounts behind a firewall but require access to grant permissions (e.g., Owner). If specified, managed identity will be used; otherwise, managed identity will not be used and your export will not be able to push data to a storage account behind a firewall. Default = (empty). | -| `‑DoNotPartition` | Optional. Indicates whether to partition the exported data into multiple files. Partitioning is recommended for reliability so this option is to disable partitioning. Default = false. | -| `‑DoNotOverwrite` | Optional. Indicates whether to overwrite previously exported data for the current month. Overwriting is recommended to keep storage size and costs down so this option is to disable overwriting. Default = false. | -| `‑Execute` | Optional. Indicates that the export should be run immediately after created. | -| `‑Backfill` | Optional. Number of months to export the data for. This is only run once at create time. Failed exports are not re-attempted. Not supported when -OneTime is set. Default = 0. | -| `‑Execute` | Optional. Indicates that the export should be run immediately after created. | -| `‑Backfill` | Optional. Number of months to export the data for. This is only run once at create time. Failed exports are not re-attempted. Not supported when -OneTime is set. Default = 0. | -| `‑ApiVersion` | Optional. API version to use when calling the Cost Management Exports API. Default = 2023-07-01-preview. | +| Name | Description | +| ---- | ----------- | +| `‑Name` | Required. Name of the export. | +| `‑Scope` | Optional. Resource ID of the scope to export data for. If empty, defaults to current subscription context. | +| `‑Dataset` | Optional. Dataset to export. Allowed values = "ActualCost", "AmortizedCost", "FocusCost", "PriceSheet", "ReservationDetails", "ReservationTransactions", "ReservationRecommendations". Default = "FocusCost". | +| `‑DatasetVersion` | Optional. Schema version of the dataset to export. Default = (latest version as of June 2024; e.g., "1.0" for FocusCost). | +| `‑DatasetFilters` | Optional. Dictionary of key/value pairs to filter the dataset with. Only applies to ReservationRecommendations dataset in 2023-07-01-preview. Valid filters are reservationScope (Shared or Single), resourceType (e.g., VirtualMachines), lookBackPeriod (Last7Days, Last30Days, Last60Days). | +| `‑Monthly` | Optional. Indicates that the export should be executed monthly (instead of daily). Default = false. | +| `‑OneTime` | Optional. Indicates that the export should only be executed once. When set, the start/end dates are the dates to query data for. Cannot be used in conjunction with the -Monthly option. | +| `‑StartDate` | Optional. Day to start running exports. Default = First day of the previous month if -OneTime is set; otherwise, tomorrow (DateTime.Now.AddDays(1)). | +| `‑EndDate` | Optional. Last day to run the export. Default = Last day of the month identified in -StartDate if -OneTime is set; otherwise, 5 years from -StartDate. | +| `‑StorageAccountId` | Required. Resource ID of the storage account to export data to. | +| `‑StorageContainer` | Optional. Name of the container to export data to. Container is created if it doesn't exist. Default = "cost-management". | +| `‑StoragePath` | Optional. Path to export data to within the storage container. Default = (scope ID). | +| `‑Location` | Optional. Indicates the Azure location to use for the managed identity used to push data to the storage account. Managed identity is required in order to work with storage accounts behind a firewall but require access to grant permissions (e.g., Owner). If specified, managed identity will be used; otherwise, managed identity will not be used and your export will not be able to push data to a storage account behind a firewall. Default = (empty). | +| `‑DoNotPartition` | Optional. Indicates whether to partition the exported data into multiple files. Partitioning is recommended for reliability so this option is to disable partitioning. Default = false. | +| `‑DoNotOverwrite` | Optional. Indicates whether to overwrite previously exported data for the current month. Overwriting is recommended to keep storage size and costs down so this option is to disable overwriting. If creating an export for FinOps hubs, we recommend you specify the -DoNotOverwrite option to improve troubleshooting. Default = false. | +| `‑Execute` | Optional. Indicates that the export should be run immediately after created. | +| `‑Backfill` | Optional. Number of months to export the data for. This is only run once at create time. Failed exports are not re-attempted. Not supported when -OneTime is set. Default = 0. | +| `‑ApiVersion` | Optional. API version to use when calling the Cost Management Exports API. Default = 2023-03-01. |
@@ -113,16 +112,16 @@ New-FinOpsCostExport ` ### Create one time export ```powershell -New-FinopsCostExport -Name 'July2023OneTime' ` +New-FinopsCostExport -Name 'July2024OneTime' ` -Scope "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ` -StorageAccountId "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/SharedStorage/providers/Microsoft.Storage/storageAccounts/ddsharedstorage" ` -DataSet ActualCost ` -OneTime ` - -StartDate "2023-07-01" ` - -EndDate "2023-07-31" + -StartDate "2024-07-01" ` + -EndDate "2024-07-31" ``` -Creates a new one time export called 'July2023OneTime' from 2023-07-01 to 2023-07-31 with Dataset = Actual and execute it once. +Creates a new one time export called 'July2024OneTime' from 2024-07-01 to 2024-07-31 with Dataset = Actual and execute it once. ### Create and run a daily export @@ -172,6 +171,7 @@ Creates a new daily export called Daily-MTD with StartDate = DateTime.Now and En ## 🧰 Related tools -{% include tools.md bicep="0" data="0" gov="0" hubs="1" opt="0" pbi="1" ps="0" %} +{% include tools.md aoe="1" bicep="0" data="0" hubs="1" pbi="1" ps="0" %}
+ diff --git a/docs/_automation/powershell/cost/Remove-FinOpsCostExport.md b/docs/_automation/powershell/cost/Remove-FinOpsCostExport.md index a5a8a6193..511d865a9 100644 --- a/docs/_automation/powershell/cost/Remove-FinOpsCostExport.md +++ b/docs/_automation/powershell/cost/Remove-FinOpsCostExport.md @@ -3,8 +3,8 @@ layout: default grand_parent: PowerShell parent: Cost Management title: Remove-FinOpsCostExport -nav_order: 1 -description: 'Delete a Cost Management export and optionally data associated with the export' +nav_order: 10 +description: Delete a Cost Management export and optionally data associated with the export. permalink: /powershell/cost/Remove-FinOpsCostExport --- @@ -27,10 +27,9 @@ Delete a Cost Management export and optionally data associated with the export. --- -The **Remove-FinOpsCostExport** command deletes a Cost Management export and optionally data associated with the export. +The **Remove-FinOpsCostExport** command deletes a Cost Management export and optionally deletes all data associated with the export from the related storage account. This command has been tested with the following API versions: - - 2023-07-01-preview (default) – Enables FocusCost and other datasets. - 2023-08-01 - 2023-03-01 @@ -41,22 +40,24 @@ This command has been tested with the following API versions: ```powershell Remove-FinOpsCostExport ` - -Name ` - -Scope ` - [-RemoveData ] ` - [-ApiVersion ] ` + [‑Name] ` + [‑Scope] ` + [‑RemoveData] ` + [[‑ApiVersion] ] ` + [‑WhatIf] ```
## 📥 Parameters -| Name | Description | -| ------------- | ---------------------------------------------------------------------------------------------------- | -| `‑Name` | Required. Name of the Cost Management export. | -| `‑Scope` | Required. Resource ID of the scope to export data for context. | -| `‑RemoveData` | Optional. Optional. Indicates that all cost data associated with the Export scope should be deleted. | -| `‑ApiVersion` | Optional. API version to use when calling the Cost Management exports API. Default = 2023-03-01. | +| Name | Description | +| ---- | ----------- | +| `‑Name` | Required. Name of the Cost Management export to delete. | +| `‑Scope` | Required. Resource ID of the scope to export data for. | +| `‑RemoveData` | Optional. Indicates that all cost data associated with the Export scope should be deleted. | +| `‑ApiVersion` | Optional. API version to use when calling the Cost Management Exports API. Default = 2023-07-01-preview. | +| `‑WhatIf` | Optional. Shows what would happen if the command runs without actually running the command. Default = false. |
@@ -66,12 +67,12 @@ Remove-FinOpsCostExport ` ```powershell Remove-FinOpsCostExport ` - -Name MyExport` - -Scope "/subscriptions/00000000-0000-0000-0000-000000000000"` + -Name MyExport ` + -Scope "/subscriptions/00000000-0000-0000-0000-000000000000" ` -RemoveData ``` -Deletes a Cost Management export and removes the exported data from the linked storage account. +Deletes a Cost Management export and deletes all exported data from the related storage account.
@@ -79,6 +80,7 @@ Deletes a Cost Management export and removes the exported data from the linked s ## 🧰 Related tools -{% include tools.md hubs="1" %} +{% include tools.md aoe="1" bicep="0" data="0" hubs="1" pbi="1" ps="0" %}
+ diff --git a/docs/_automation/powershell/cost/Start-FinOpsCostExport.md b/docs/_automation/powershell/cost/Start-FinOpsCostExport.md index f3c8ce477..712aebdba 100644 --- a/docs/_automation/powershell/cost/Start-FinOpsCostExport.md +++ b/docs/_automation/powershell/cost/Start-FinOpsCostExport.md @@ -3,8 +3,8 @@ layout: default grand_parent: PowerShell parent: Cost Management title: Start-FinOpsCostExport -nav_order: 1 -description: 'Initiates a Cost Management export run for the most recent period.' +nav_order: 10 +description: Initiates a Cost Management export run for the most recent period. permalink: /powershell/cost/Start-FinOpsCostExport --- @@ -30,9 +30,9 @@ Initiates a Cost Management export run for the most recent period. The **Start-FinOpsCostExport** command runs a Cost Management export for the most recent period using the Run API. This command has been tested with the following API versions: - - 2023-07-01-preview (default) – Enables FocusCost and other datasets. - 2023-08-01 +- 2023-03-01
@@ -40,26 +40,26 @@ This command has been tested with the following API versions: ```powershell Start-FinOpsCostExport ` - [-Name] ` - [-Scope ] ` - [-StartDate ] ` - [-EndDate ] ` - [-Backfill ] ` - [-ApiVersion ] + [‑Name] ` + [[‑Scope] ] ` + [‑StartDate ] ` + [‑EndDate ] ` + [‑Backfill ] ` + [‑ApiVersion ] ```
## 📥 Parameters -| Name | Description | -| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `‑Name` | Required. Name of the export. | -| `‑Scope` | Optional. Resource ID of the scope to export data for. If empty, defaults to current subscription context. | -| `‑StartDate` | Optional. Day to start pulling the data for. If not set, the export will use the dates defined in the export configuration. | -| `‑EndDate` | Optional. Last day to pull data for. If not set and -StartDate is set, -EndDate will use the last day of the month. If not set and -StartDate is not set, the export will use the dates defined in the export configuration. | -| `‑Backfill` | Optional. Number of months to export the data for. Make note of throttling (429) errors. This is only run once. Failed exports are not re-attempted. Default = 0. | -| `‑ApiVersion` | Optional. API version to use when calling the Cost Management Exports API. Default = 2023-07-01-preview. | +| Name | Description | +| ---- | ----------- | +| `‑Name` | Required. Name of the export. | +| `‑Scope` | Optional. Resource ID of the scope to export data for. If empty, defaults to current subscription context. | +| `‑StartDate` | Optional. Day to start pulling the data for. If not set, the export will use the dates defined in the export configuration. | +| `‑EndDate` | Optional. Last day to pull data for. If not set and -StartDate is set, -EndDate will use the last day of the month. If not set and -StartDate is not set, the export will use the dates defined in the export configuration. | +| `‑Backfill` | Optional. Number of months to export the data for. Make note of throttling (429) errors. This is only run once. Failed exports are not re-attempted. Default = 0. | +| `‑ApiVersion` | Optional. API version to use when calling the Cost Management Exports API. Default = 2023-07-01-preview. |
@@ -95,6 +95,7 @@ Runs an export called 'CostExport' for the previous 12 months. ## 🧰 Related tools -{% include tools.md hubs="1" pbi="1" %} +{% include tools.md aoe="1" bicep="0" data="0" hubs="1" pbi="1" ps="0" %}
+ diff --git a/docs/_automation/powershell/data/Get-FinOpsPricingUnit.md b/docs/_automation/powershell/data/Get-FinOpsPricingUnit.md index 9ed547e4a..ee7a1eaf7 100644 --- a/docs/_automation/powershell/data/Get-FinOpsPricingUnit.md +++ b/docs/_automation/powershell/data/Get-FinOpsPricingUnit.md @@ -4,7 +4,7 @@ grand_parent: PowerShell parent: Open data title: Get-FinOpsPricingUnit nav_order: 10 -description: 'Gets a pricing unit, distinct unit, and block size' +description: Gets a pricing unit with its corresponding distinct unit and block size. permalink: /powershell/data/Get-FinOpsPricingUnit --- @@ -29,9 +29,7 @@ Gets a pricing unit with its corresponding distinct unit and block size. The **Get-FinOpsPricingUnit** command returns a pricing unit (aka unit of measure) with the singular, distinct unit based on applicable block pricing rules, and the pricing block size. -
- _Block pricing is when a service is measured in groups of units (e.g., 100 hours)._ -
+Block pricing is when a service is measured in groups of units (e.g., 100 hours).
@@ -39,20 +37,20 @@ The **Get-FinOpsPricingUnit** command returns a pricing unit (aka unit of measur ```powershell Get-FinOpsPricingUnit ` - [[-UnitOfMeasure] ] ` - [-DistinctUnits ] ` - [-BlockSize ] + [[‑UnitOfMeasure] ] ` + [‑DistinctUnits ] ` + [‑BlockSize ] ```
## 📥 Parameters -| Name | Description | -| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -| UnitOfMeasure | Optional. Unit of measure (aka pricing unit) value from a Cost Management cost/usage details or price sheet dataset. Accepts wildcards. Default = \* (all). | -| DistinctUnits | Optional. The distinct unit for the pricing unit without block pricing. Accepts wildcards. Default = \* (all). | -| BlockSize | Optional. The number of units for block pricing (e.g., 100 for "100 Hours"). Default = null (all). | +| Name | Description | +| ---- | ----------- | +| `‑UnitOfMeasure` | Optional. Unit of measure (aka pricing unit) value from a Cost Management cost/usage details or price sheet dataset. Accepts wildcards. Default = * (all). | +| `‑DistinctUnits` | Optional. The distinct unit for the pricing unit without block pricing. Accepts wildcards. Default = * (all). | +| `‑BlockSize` | Optional. The number of units for block pricing (e.g., 100 for "100 Hours"). Default = null (all). |
@@ -80,6 +78,7 @@ Returns all pricing units measured in gigabytes. ## 🧰 Related tools -{% include tools.md data="1" %} +{% include tools.md aoe="0" bicep="0" data="1" hubs="1" pbi="1" ps="0" %}
+ diff --git a/docs/_automation/powershell/data/Get-FinOpsRegion.md b/docs/_automation/powershell/data/Get-FinOpsRegion.md index aef3403e9..0289e8686 100644 --- a/docs/_automation/powershell/data/Get-FinOpsRegion.md +++ b/docs/_automation/powershell/data/Get-FinOpsRegion.md @@ -3,8 +3,8 @@ layout: default grand_parent: PowerShell parent: Open data title: Get-FinOpsRegion -nav_order: 20 -description: 'Gets an Azure region ID and name' +nav_order: 10 +description: Gets an Azure region ID and name to clean up Cost Management cost data during ingestion. permalink: /powershell/data/Get-FinOpsRegion --- @@ -35,20 +35,22 @@ The **Get-FinOpsRegion** command returns an Azure region ID and name based on th ```powershell Get-FinOpsRegion ` - [[-ResourceLocation] ] ` - [-RegionId ] ` - [-RegionName ] + [[‑ResourceLocation] ] ` + [‑RegionId ] ` + [‑RegionName ] ` + [‑IncludeResourceLocation] ```
## 📥 Parameters -| Name | Description | -| --------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | -| ResouceLocation | Optional. Resource location value from a Cost Management cost/usage details dataset. Accepts wildcards. Default = \* (all). | -| RegionId | Optional. Azure region ID (lowercase English name without spaces). Accepts wildcards. Default = \* (all). | -| RegionName | Optional. Azure region name (title case English name with spaces). Accepts wildcards. Default = \* (all).IncludeResourceLocation | Optional. Indicates whether to include the ResourceLocation property in the output. Default = false. | +| Name | Description | +| ---- | ----------- | +| `‑ResourceLocation` | Optional. Resource location value from a Cost Management cost/usage details dataset. Accepts wildcards. Default = * (all). | +| `‑RegionId` | Optional. Azure region ID (lowercase English name without spaces). Accepts wildcards. Default = * (all). | +| `‑RegionName` | Optional. Azure region name (title case English name with spaces). Accepts wildcards. Default = * (all). | +| `‑IncludeResourceLocation` | Optional. Indicates whether to include the ResourceLocation property in the output. Default = false. |
@@ -76,6 +78,7 @@ Returns all Asia regions with the original Cost Management ResourceLocation valu ## 🧰 Related tools -{% include tools.md data="1" %} +{% include tools.md aoe="0" bicep="0" data="1" hubs="1" pbi="1" ps="0" %}
+ diff --git a/docs/_automation/powershell/data/Get-FinOpsResourceType.md b/docs/_automation/powershell/data/Get-FinOpsResourceType.md index 8feceeff7..07fe973c1 100644 --- a/docs/_automation/powershell/data/Get-FinOpsResourceType.md +++ b/docs/_automation/powershell/data/Get-FinOpsResourceType.md @@ -3,8 +3,8 @@ layout: default grand_parent: PowerShell parent: Open data title: Get-FinOpsResourceType -nav_order: 30 -description: 'Gets an Azure resource type and readable display names' +nav_order: 10 +description: Gets details about an Azure resource type. permalink: /powershell/data/Get-FinOpsResourceType --- @@ -35,18 +35,18 @@ The **Get-FinOpsResourceType** command returns an Azure resource type with reada ```powershell Get-FinOpsResourceType ` - [[-ResourceType] ] ` - [-IsPreview ] + [[‑ResourceType] ] ` + [‑IsPreview ] ```
## 📥 Parameters -| Name | Description | -| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `‑ResourceType` | Optional. Azure resource type value. Accepts wildcards. Default = \* (all). | -| `‑IsPreview` | Optional. Indicates whether to include or exclude resource types that are in preview. Note: Not all resource types self-identify as being in preview, so this may not be completely accurate. Default = null (include all). | +| Name | Description | +| ---- | ----------- | +| `‑ResourceType` | Optional. Azure resource type value. Accepts wildcards. Default = * (all). | +| `‑IsPreview` | Optional. Indicates whether to include or exclude resource types that are in preview. Note: Not all resource types self-identify as being in preview, so this may not be completely accurate. Default = null (include all). |
@@ -74,6 +74,7 @@ Returns all resource types that are not in preview. ## 🧰 Related tools -{% include tools.md data="1" hubs="1" %} +{% include tools.md aoe="0" bicep="0" data="1" hubs="1" pbi="1" ps="0" %}
+ diff --git a/docs/_automation/powershell/data/Get-FinOpsService.md b/docs/_automation/powershell/data/Get-FinOpsService.md index 92c2465e1..2d1297891 100644 --- a/docs/_automation/powershell/data/Get-FinOpsService.md +++ b/docs/_automation/powershell/data/Get-FinOpsService.md @@ -3,13 +3,13 @@ layout: default grand_parent: PowerShell parent: Open data title: Get-FinOpsService -nav_order: 40 -description: 'Gets the name and category for a service, publisher, and cloud provider' +nav_order: 10 +description: Gets the name and category for a service, publisher, and cloud provider. permalink: /powershell/data/Get-FinOpsService --- Get-FinOpsService -Gets the name and category for a service, publisher, and cloud provider to support FinOps Open Cost and Usage Specification (FOCUS). +Gets the name and category for a service, publisher, and cloud provider. {: .fs-6 .fw-300 } [Syntax](#-syntax){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-4 } @@ -29,9 +29,7 @@ Gets the name and category for a service, publisher, and cloud provider to suppo The **Get-FinOpsService** command returns service details based on the specified filters. This command is designed to help map Cost Management cost data to the FinOps Open Cost and Usage Specification (FOCUS) schema but can also be useful for general data cleansing. -
- _Both `ConsumedService` and `ResourceType` are required to find a unique service in many cases._ -
+Please note that both ConsumedService and ResourceType are required to find a unique service in many cases.
@@ -39,43 +37,41 @@ The **Get-FinOpsService** command returns service details based on the specified ```powershell Get-FinOpsService ` - [[-ConsumedService] ] ` - [[-ResourceId] ] ` - [[-ResourceType] ] ` - [-ServiceName ] ` - [-ServiceCategory ] ` - [-ServiceModel ] ` - [-Environment ] ` - [-PublisherName ] ` - [-PublisherCategory ] + [[‑ConsumedService] ] ` + [[‑ResourceId] ] ` + [[‑ResourceType] ] ` + [‑ServiceName ] ` + [‑ServiceCategory ] ` + [‑ServiceModel ] ` + [‑Environment ] ` + [‑PublisherName ] ` + [‑PublisherCategory ] ```
## 📥 Parameters -| Name | Description | -| -------------------- | ------------------------------------------------------------------------------------------------------------------------- | -| `‑ConsumedService` | Optional. ConsumedService value from a Cost Management cost/usage details dataset. Accepts wildcards. Default = \* (all). | -| `‑ResourceId` | Optional. The Azure resource ID for resource you want to look up. Accepts wildcards. Default = \* (all). | -| `‑ResourceType` | Optional. The Azure resource type for the resource you want to find the service for. Default = null (all). | -| `‑ServiceName` | Optional. The service name to find. Default = null (all). | -| `‑ServiceCategory` | Optional. The service category to find services for. Default = null (all). | -| `‑Servicemodel` | Optional. The service model the service aligns to. Expected values: IaaS, PaaS, SaaS. Default = null (all). | -| `‑Environment` | Optional. The environment the service runs in. Expected values: Cloud, Hybrid. Default = null (all). | -| `‑PublisherName` | Optional. The publisher name to find services for. Default = null (all). | -| `‑PublisherCategory` | Optional. The publisher category to find services for. Default = null (all). | +| Name | Description | +| ---- | ----------- | +| `‑ConsumedService` | Optional. ConsumedService value from a Cost Management cost/usage details dataset. Accepts wildcards. Default = * (all). | +| `‑ResourceId` | Optional. The Azure resource ID for resource you want to look up. Accepts wildcards. Default = * (all). | +| `‑ResourceType` | Optional. The Azure resource type for the resource you want to find the service for. Default = null (all). | +| `‑ServiceName` | Optional. The service name to find. Default = null (all). | +| `‑ServiceCategory` | Optional. The service category to find services for. Default = null (all). | +| `‑ServiceModel` | Optional. The service model the service aligns to. Expected values: IaaS, PaaS, SaaS. Default = null (all). | +| `‑Environment` | Optional. The environment the service runs in. Expected values: Cloud, Hybrid, On-Premises. Default = null (all). | +| `‑PublisherName` | Optional. The publisher name to find services for. Default = null (all). | +| `‑PublisherCategory` | Optional. The publisher category to find services for. Default = null (all). |
## 🌟 Examples -### Get a specific region +### Get services based on filter ```powershell -Get-FinOpsService ` - -ConsumedService "Microsoft.C*" ` - -ResourceType "Microsoft.Compute/virtualMachines" +Get-FinOpsService -ConsumedService "Microsoft.C*" ``` Returns all services with a resource provider that starts with "Microsoft.C". @@ -86,6 +82,7 @@ Returns all services with a resource provider that starts with "Microsoft.C". ## 🧰 Related tools -{% include tools.md data="1" pbi="1" hubs="1" %} +{% include tools.md aoe="0" bicep="0" data="1" hubs="1" pbi="1" ps="0" %}
+ diff --git a/docs/_automation/powershell/hubs/Deploy-FinOpsHub.md b/docs/_automation/powershell/hubs/Deploy-FinOpsHub.md index b4714f7ed..51b88ae24 100644 --- a/docs/_automation/powershell/hubs/Deploy-FinOpsHub.md +++ b/docs/_automation/powershell/hubs/Deploy-FinOpsHub.md @@ -3,8 +3,8 @@ layout: default grand_parent: PowerShell parent: FinOps hubs title: Deploy-FinOpsHub -nav_order: 1 -description: 'Deploys a FinOps hub instance.' +nav_order: 10 +description: Deploys a FinOps hub instance. permalink: /powershell/hubs/Deploy-FinOpsHub --- @@ -27,7 +27,7 @@ Deploys a FinOps hub instance. --- -The **Deploy-FinOpsHub** command either creates a new or updates an existing FinOps hub instance by deploying an Azure Resource Manager deployment template. The FinOps hub template is downloaded from GitHub. To learn more about the template, see the [FinOps hub template](../../../_reporting/hubs/template.md). +The **Deploy-FinOpsHub** command either creates a new or updates an existing FinOps hub instance by deploying an Azure Resource Manager deployment template. The FinOps hub template is downloaded from GitHub. Deploy-FinOpsHub calls [Initialize-FinOpsHubDeployment](Initialize-FinOpsHubDeployment.md) before deploying the template. @@ -37,29 +37,30 @@ Deploy-FinOpsHub calls [Initialize-FinOpsHubDeployment](Initialize-FinOpsHubDepl ```powershell Deploy-FinOpsHub ` - -Name ` - -ResourceGroup ` - -Location ` - [-Version ] ` - [-Preview] ` - [-StorageSku ] ` - [-Tags ] ` - [] + [‑Name] ` + [‑ResourceGroupName] ` + [‑Location] ` + [[‑Version] ] ` + [‑Preview] ` + [[‑StorageSku] ] ` + [[‑Tags] ] ` + [‑WhatIf] ```
## 📥 Parameters -| Name | Description | -| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `‑Name` | Required. Name of the FinOps hub instance. | -| `‑ResourceGroup` | Required. Name of the resource group to deploy to. Will be created if it doesn't exist. | -| `‑Location` | Required. Azure location to execute the deployment from. | -| `‑Version` | Optional. Version of the FinOps hub template to use. Default = "latest". | -| `‑Preview` | Optional. Indicates that preview releases should also be included. Default = false. | -| `‑StorageSku` | Optional. Storage account SKU. Premium_LRS = Lowest cost, Premium_ZRS = High availability. Note Standard SKUs are not available for Data Lake gen2 storage. Default = "Premium_LRS". | -| `‑Tags` | Optional. Tags for all resources. | +| Name | Description | +| ---- | ----------- | +| `‑Name` | Required. Name of the FinOps hub instance. | +| `‑ResourceGroupName` | Required. Name of the resource group to deploy to. Will be created if it doesn't exist. | +| `‑Location` | Required. Azure location to execute the deployment from. | +| `‑Version` | Optional. Version of the FinOps hub template to use. Default = "latest". | +| `‑Preview` | Optional. Indicates that preview releases should also be included. Default = false. | +| `‑StorageSku` | Optional. Storage account SKU. Premium_LRS = Lowest cost, Premium_ZRS = High availability. Note Standard SKUs are not available for Data Lake gen2 storage. Default = "Premium_LRS". | +| `‑Tags` | Optional. Tags for all resources. | +| `‑WhatIf` | Optional. Shows what would happen if the command runs without actually running the command. Default = false. |
@@ -70,7 +71,7 @@ Deploy-FinOpsHub ` ```powershell Deploy-FinOpsHub ` -Name MyHub ` - -ResourceGroup MyNewResourceGroup ` + -ResourceGroupName MyNewResourceGroup ` -Location westus ``` @@ -81,7 +82,7 @@ Deploys a FinOps hub instance named MyHub to the MyNewResourceGroup resource gro ```powershell Deploy-FinOpsHub ` -Name MyHub ` - -ResourceGroup MyExistingResourceGroup ` + -ResourceGroupName MyExistingResourceGroup ` -Location westus ` -Version 0.1.1 ``` @@ -94,6 +95,7 @@ Deploys a FinOps hub instance named MyHub to the MyExistingResourceGroup resourc ## 🧰 Related tools -{% include tools.md hubs="1" %} +{% include tools.md aoe="1" bicep="0" data="0" hubs="1" pbi="1" ps="0" %}
+ diff --git a/docs/_automation/powershell/hubs/Get-FinOpsHub.md b/docs/_automation/powershell/hubs/Get-FinOpsHub.md index f727cc799..a6731c654 100644 --- a/docs/_automation/powershell/hubs/Get-FinOpsHub.md +++ b/docs/_automation/powershell/hubs/Get-FinOpsHub.md @@ -3,8 +3,8 @@ layout: default grand_parent: PowerShell parent: FinOps hubs title: Get-FinOpsHub -nav_order: 2 -description: 'Gets details about a FinOps hub instance.' +nav_order: 10 +description: Gets details about a FinOps hub instance. permalink: /powershell/hubs/Get-FinOpsHub --- @@ -27,7 +27,7 @@ Gets details about a FinOps hub instance. --- -The Get-FinOpsHubs command calls GitHub to retrieve all toolkit releases, then filters the list based on the specified options. +The **Get-FinOpsHub** command gets details about a FinOps hub instance using the cm-resource-parent tag to identify hub resources.
@@ -35,19 +35,18 @@ The Get-FinOpsHubs command calls GitHub to retrieve all toolkit releases, then f ```powershell Get-FinOpsHub ` - [[-Name] ] ` - [-ResourceGroupName ] ` - [] + [[‑Name] ] ` + [‑ResourceGroupName ] ```
## 📥 Parameters -| Name | Description | -| -------------------- | ---------------------------------------------------------------------------------------- | -| '‑Name' | Optional. Name of the FinOps hub instance. Supports wildcards. | -| '‑ResourceGroupName' | Optional. Name of the resource group the FinOps hub was deployed to. Supports wildcards. | +| Name | Description | +| ---- | ----------- | +| `‑Name` | Optional. Name of the FinOps hub instance. Supports wildcards. | +| `‑ResourceGroupName` | Optional. Name of the resource group the FinOps hub was deployed to. Supports wildcards. |
@@ -75,7 +74,7 @@ Returns all FinOps hubs that start with 'foo'. Get-FinOpsHub -ResourceGroupName foo ``` -Returns all hubs in the 'foo' resource group. +Returns all resources associated with a FinOps hub in the 'foo' resource group. ### Get named hubs in a resource group @@ -91,6 +90,7 @@ Returns all FinOps hubs named 'foo' in the 'bar' resource group. ## 🧰 Related tools -{% include tools.md hubs="1" %} +{% include tools.md aoe="1" bicep="0" data="0" hubs="1" pbi="1" ps="0" %}
+ diff --git a/docs/_automation/powershell/hubs/Initialize-FinOpsHubDeployment.md b/docs/_automation/powershell/hubs/Initialize-FinOpsHubDeployment.md index 215042f1a..af9d316b6 100644 --- a/docs/_automation/powershell/hubs/Initialize-FinOpsHubDeployment.md +++ b/docs/_automation/powershell/hubs/Initialize-FinOpsHubDeployment.md @@ -3,8 +3,8 @@ layout: default grand_parent: PowerShell parent: FinOps hubs title: Initialize-FinOpsHubDeployment -nav_order: 1 -description: 'Initialize a FinOps hub deployment.' +nav_order: 10 +description: Initialize a FinOps hub deployment in order to enable resource group owners to deployment hubs via the portal. permalink: /powershell/hubs/Initialize-FinOpsHubDeployment --- @@ -35,18 +35,16 @@ The **Initialize-FinOpsHubDeployment** command performs any initialization tasks ```powershell Initialize-FinOpsHubDeployment ` - [-WhatIf ] + [‑WhatIf] ```
## 📥 Parameters -| Name | Description | -| --------- | ---------------------------------------------------------------------------------- | -| '‑WhatIf' | Optional. Shows what would happen if the command runs without actually running it. | - -| +| Name | Description | +| ---- | ----------- | +| `‑WhatIf` | Optional. Shows what would happen if the command runs without actually running the command. Default = false. |
@@ -55,8 +53,7 @@ Initialize-FinOpsHubDeployment ` ### Test initialize FinOps hub deployment ```powershell -Initialize-FinOpsHubDeployment ` - -WhatIf +Initialize-FinOpsHubDeployment -WhatIf ``` Shows what would happen if the command runs without actually running it. @@ -67,6 +64,7 @@ Shows what would happen if the command runs without actually running it. ## 🧰 Related tools -{% include tools.md hubs="1" %} +{% include tools.md aoe="1" bicep="0" data="0" hubs="1" pbi="1" ps="0" %}
+ diff --git a/docs/_automation/powershell/hubs/Register-FinOpsHubProviders.md b/docs/_automation/powershell/hubs/Register-FinOpsHubProviders.md index 27b9349d8..e62abd95c 100644 --- a/docs/_automation/powershell/hubs/Register-FinOpsHubProviders.md +++ b/docs/_automation/powershell/hubs/Register-FinOpsHubProviders.md @@ -3,8 +3,8 @@ layout: default grand_parent: PowerShell parent: FinOps hubs title: Register-FinOpsHubProviders -nav_order: 1 -description: 'Register Azure resource providers required for FinOps hub.' +nav_order: 10 +description: Register Azure resource providers required for FinOps hub. permalink: /powershell/hubs/Register-FinOpsHubProviders --- @@ -37,28 +37,25 @@ To register a resource provider, you must have Contributor access (or the /regis ```powershell Register-FinOpsHubProviders ` - [-WhatIf ] ` + [‑WhatIf] ```
## 📥 Parameters -| Name | Description | -| --------- | ---------------------------------------------------------------------------------- | +| Name | Description | +| ---- | ----------- | | `‑WhatIf` | Optional. Shows what would happen if the command runs without actually running it. | -| -
## 🌟 Examples -### Test register FinOps hub providers +### Example 1 ```powershell -Register-FinOpsHubProviders ` - -WhatIf +Register-FinOpsHubProviders -WhatIf ``` Shows what would happen if the command runs without actually running it. @@ -69,6 +66,7 @@ Shows what would happen if the command runs without actually running it. ## 🧰 Related tools -{% include tools.md hubs="1" %} +{% include tools.md aoe="1" bicep="0" data="0" hubs="1" pbi="1" ps="0" %}
+ diff --git a/docs/_automation/powershell/hubs/Remove-FinOpsHub.md b/docs/_automation/powershell/hubs/Remove-FinOpsHub.md index 38f874d18..727b713fd 100644 --- a/docs/_automation/powershell/hubs/Remove-FinOpsHub.md +++ b/docs/_automation/powershell/hubs/Remove-FinOpsHub.md @@ -3,13 +3,13 @@ layout: default grand_parent: PowerShell parent: FinOps hubs title: Remove-FinOpsHub -nav_order: 1 -description: 'Remove a FinOps hub instance.' +nav_order: 10 +description: Delete a FinOps hub instance and optionally keep the storage account hosting cost data. permalink: /powershell/hubs/Remove-FinOpsHub --- Remove-FinOpsHub -Delete a FinOps hub instance, including all dependent resources. +Delete a FinOps hub instance and optionally keep the storage account hosting cost data. {: .fs-6 .fw-300 } [Syntax](#-syntax){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-4 } @@ -27,7 +27,7 @@ Delete a FinOps hub instance, including all dependent resources. --- -The **Remove-FinOpsHub** command removes a FinOps hub instance and optionally keep the storage account hosting cost data. +The **Remove-FinOpsHub** command deletes a FinOps Hub instance and optionally deletes the storage account hosting cost data. The comamnd returns a boolean value indicating whether all resources were successfully deleted. @@ -36,28 +36,36 @@ The comamnd returns a boolean value indicating whether all resources were succes ## 🧮 Syntax ```powershell +# Delete by name Remove-FinOpsHub ` - [-Name] ` - [-ResourceGroup ] ` - [-KeepStorageAccount] + ‑Name ` + [‑ResourceGroupName ] ` + [‑KeepStorageAccount] ` + [‑Force] ` + [‑WhatIf] ``` ```powershell +# Delete by reference Remove-FinOpsHub ` - [-InputObject] ` - [-KeepStorageAccount] + ‑InputObject ` + [‑KeepStorageAccount] ` + [‑Force] ` + [‑WhatIf] ```
## 📥 Parameters -| Name | Description | -| --------------------- | ----------------------------------------------------------------------------------------------- | -| `‑Name` | Required. Name of the FinOps hub instance. | -| `‑InputObject` | Required when specifying InputObject. Expected object is the output of Get-FinOpsHub. | -| `‑ResourceGroup` | Optional when specifying Name. Resource Group Name for the FinOps Hub. | -| `‑KeepStorageAccount` | Optional. Indicates that the storage account associated with the FinOps Hub should be retained. | +| Name | Description | +| ---- | ----------- | +| `‑Name` | Required if not specifying InputObject. Name of the FinOps hub instance. | +| `‑ResourceGroupName` | Optional when specifying Name. Resource group name for the FinOps Hub. | +| `‑InputObject` | Required if not specifying Name. Expected object is the output of Get-FinOpsHub. | +| `‑KeepStorageAccount` | Optional. Indicates that the storage account associated with the FinOps Hub should be retained. Default = false. | +| `‑Force` | Optional. Indicates that the hub instance should be deleted without an additional confirmation. Default = false. | +| `‑WhatIf` | Optional. Shows what would happen if the command runs without actually running the command. Default = false. |
@@ -68,7 +76,7 @@ Remove-FinOpsHub ` ```powershell Remove-FinOpsHub ` -Name MyHub ` - -ResourceGroup MyRG ` + -ResourceGroupName MyRG ` -KeepStorageAccount ``` @@ -80,6 +88,7 @@ Deletes a FinOps Hub named MyHub and deletes all associated resource except the ## 🧰 Related tools -{% include tools.md hubs="1" %} +{% include tools.md aoe="1" bicep="0" data="0" hubs="1" pbi="1" ps="0" %}
+ diff --git a/docs/_automation/powershell/hubs/Remove-FinOpsHubScope.md b/docs/_automation/powershell/hubs/Remove-FinOpsHubScope.md index 99a192bbb..db2a97067 100644 --- a/docs/_automation/powershell/hubs/Remove-FinOpsHubScope.md +++ b/docs/_automation/powershell/hubs/Remove-FinOpsHubScope.md @@ -3,8 +3,8 @@ layout: default grand_parent: PowerShell parent: FinOps hubs title: Remove-FinOpsHubScope -nav_order: 1 -description: 'Stops monitoring a scope within a FinOps hub instance.' +nav_order: 10 +description: Stops monitoring a scope within a FinOps hub instance. permalink: /powershell/hubs/Remove-FinOpsHubScope --- @@ -27,7 +27,7 @@ Stops monitoring a scope within a FinOps hub instance. --- -The **Remove-FinOpsHubScope** command removes a scope from being monitored by a FinOps hub instance. Data related to that scope is kept by default. To remove the data, use the `-RemoveData` option. +The **Remove-FinOpsHubScope** command removes a scope from being monitored by a FinOps hub instance. Data related to that scope is kept by default. To remove the data, use the -RemoveData option.
@@ -35,22 +35,24 @@ The **Remove-FinOpsHubScope** command removes a scope from being monitored by a ```powershell Remove-FinOpsHubScope ` - [-Id] ` - -HubName - [-HubResourceGroupName ] - [-RemoveData] + [‑Id] ` + [‑HubName] ` + [[‑HubResourceGroupName] ] ` + [‑RemoveData] ` + [‑WhatIf] ```
## 📥 Parameters -| Name | Description | -| --------------------- | ----------------------------------------------------------------------------------------------- | -|`‑Id`| Required resource ID of the scope to remove. -|`‑HubName`| Required. Name of the FinOps hub instance. -|`‑HubResourceGroupName`| Optional. Name of the resource group the FinOps hub was deployed to. -|`‑RemoveData`| Optional. Indicates whether to remove data for this scope from storage. Default = false +| Name | Description | +| ---- | ----------- | +| `‑Id` | Required resource ID of the scope to remove. | +| `‑HubName` | Required. Name of the FinOps hub instance. | +| `‑HubResourceGroupName` | Optional. Name of the resource group the FinOps hub was deployed to. | +| `‑RemoveData` | Optional. Indicates whether to remove data for this scope from storage. Default = false | +| `‑WhatIf` | Optional. Shows what would happen if the command runs without actually running the command. Default = false. |
@@ -62,7 +64,7 @@ Remove-FinOpsHubScope ` Remove-FinOpsHubScope -Id "/providers/Microsoft.Billing/billingAccounts/123" -HubName "FooHub" ``` -Removes the exports configured to use the FooHub hub instance. Existing data is retained in the storage account. +Deletes the exports configured to use the FooHub hub instance. Existing data is retained in the storage account. ### Remove subscription and historical data @@ -70,7 +72,7 @@ Removes the exports configured to use the FooHub hub instance. Existing data is Remove-FinOpsHubScope -Id "/subscriptions/##-#-#-#-###" -HubName "FooHub" -RemoveData ``` -Removes the exports configured to use the FooHub hub instance and removes data for that scope. +Deletes the exports configured to use the FooHub hub instance and removes data for that scope.
@@ -78,6 +80,7 @@ Removes the exports configured to use the FooHub hub instance and removes data f ## 🧰 Related tools -{% include tools.md hubs="1" pbi="1" %} +{% include tools.md aoe="1" bicep="0" data="0" hubs="1" pbi="1" ps="0" %}
+ diff --git a/docs/_automation/powershell/toolkit/Get-FinOpsToolkitVersion.md b/docs/_automation/powershell/toolkit/Get-FinOpsToolkitVersion.md index cc2af0960..8707b8bfe 100644 --- a/docs/_automation/powershell/toolkit/Get-FinOpsToolkitVersion.md +++ b/docs/_automation/powershell/toolkit/Get-FinOpsToolkitVersion.md @@ -3,8 +3,8 @@ layout: default grand_parent: PowerShell parent: Toolkit title: Get-FinOpsToolkitVersion -nav_order: 1 -description: 'Gets available versions from published FinOps toolkit releases.' +nav_order: 10 +description: Gets available versions from published FinOps toolkit releases. permalink: /powershell/toolkit/Get-FinOpsToolkitVersion --- @@ -21,12 +21,13 @@ Gets available versions from published FinOps toolkit releases. - [🧮 Syntax](#-syntax) - [📥 Parameters](#-parameters) - [🌟 Examples](#-examples) +- [🧰 Related tools](#-related-tools) --- -The Get-FinOpsToolkitVersions command calls GitHub to retrieve all toolkit releases, then filters the list based on the specified options. +The **Get-FinOpsToolkitVersion** command calls GitHub to retrieve all toolkit releases, then filters the list based on the specified options.
@@ -34,19 +35,18 @@ The Get-FinOpsToolkitVersions command calls GitHub to retrieve all toolkit relea ```powershell Get-FinOpsToolkitVersion ` - [-Latest] ` - [-Preview] ` - [] + [‑Latest] ` + [‑Preview] ```
## 📥 Parameters -| Name | Description | -| ------- | ------------------------------------------------------------------------------------------ | -| Latest | Optional. Indicates that only the most recent release should be returned. Default = false. | -| Preview | Optional. Indicates that preview releases should also be included. Default = false. | +| Name | Description | +| ---- | ----------- | +| `‑Latest` | Optional. Indicates that only the most recent release should be returned. Default = false. | +| `‑Preview` | Optional. Indicates that preview releases should also be included. Default = false. |
@@ -77,3 +77,12 @@ Get-FinOpsToolkitVersion -Preview Returns all release versions, including preview releases.
+ +--- + +## 🧰 Related tools + +{% include tools.md aoe="1" bicep="0" hubs="1" wb="1" pbi="1" ps="0" %} + +
+ diff --git a/src/powershell/Public/Deploy-FinOpsHub.ps1 b/src/powershell/Public/Deploy-FinOpsHub.ps1 index 0d67d9714..85bfc0303 100644 --- a/src/powershell/Public/Deploy-FinOpsHub.ps1 +++ b/src/powershell/Public/Deploy-FinOpsHub.ps1 @@ -32,13 +32,22 @@ Optional. Tags for all resources. .EXAMPLE - Deploy-FinOpsHub -Name MyHub -ResourceGroupName MyNewResourceGroup -Location westus + Deploy-FinOpsHub ` + -Name MyHub ` + -ResourceGroupName MyNewResourceGroup ` + -Location westus + ### Deploy latest version Deploys a FinOps hub instance named MyHub to the MyNewResourceGroup resource group. If the resource group does not exist, it will be created. If the hub already exists, it will be updated to the latest version. - + .EXAMPLE - Deploy-FinOpsHub -Name MyHub -ResourceGroupName MyExistingResourceGroup -Location westus -Version 0.1.1 - + Deploy-FinOpsHub ` + -Name MyHub ` + -ResourceGroupName MyExistingResourceGroup ` + -Location westus ` + -Version 0.1.1 + + ### Deploy specific version Deploys a FinOps hub instance named MyHub to the MyExistingResourceGroup resource group using version 0.1.1 of the template. This version is required in order to deploy to Azure Gov or Azure China as of February 2024 since FOCUS exports are not available from Cost Management in those environments. If the resource group does not exist, it will be created. If the hub already exists, it will be updated to version 0.1.1. .LINK diff --git a/src/powershell/Public/Get-FinOpsCostExport.ps1 b/src/powershell/Public/Get-FinOpsCostExport.ps1 index 12cfff158..3296b2ebc 100644 --- a/src/powershell/Public/Get-FinOpsCostExport.ps1 +++ b/src/powershell/Public/Get-FinOpsCostExport.ps1 @@ -3,14 +3,16 @@ <# .SYNOPSIS - Get list of Cost Management exports. + Get a list of Cost Management exports. .DESCRIPTION The Get-FinOpsCostExport command gets a list of Cost Management exports for a given scope. This command has been tested with the following API versions: + - 2023-07-01-preview (default) – Enables FocusCost and other datasets. - 2023-08-01 + - 2023-03-01 .PARAMETER Name Optional. Name of the export. Supports wildcards. @@ -36,34 +38,54 @@ .PARAMETER ApiVersion Optional. API version to use when calling the Cost Management exports API. Default = 2023-07-01-preview. + .OUTPUTS + FinOpsCostExport + .EXAMPLE - Get-FinOpsCostExport -Scope "/subscriptions/00000000-0000-0000-0000-000000000000" + Get-FinOpsCostExport ` + -Scope "/subscriptions/00000000-0000-0000-0000-000000000000" + ### Get cost exports for a subscription Gets all exports for a subscription. Does not include exports in nested resource groups. .EXAMPLE - Get-FinOpsCostExport -Name mtd* -Scope "providers/Microsoft.Billing/billingAccounts/00000000" + Get-FinOpsCostExport ` + -Name mtd* ` + -Scope "providers/Microsoft.Billing/billingAccounts/00000000" + ### Get exports matching a wildcard name Gets export with name matching wildcard mtd* within the specified billing account scope. Does not include exports in nested resource groups. .EXAMPLE - Get-FinOpsCostExport -Dataset "AmortizedCost" + Get-FinOpsCostExport ` + -Dataset "AmortizedCost" + ### Get amortized cost exports Gets all exports within the current context subscription scope and filtered by dataset AmortizedCost. .EXAMPLE - Get-FinOpsCostExport -Scope "/subscriptions/00000000-0000-0000-0000-000000000000" -StorageAccountId "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Storage/storageAccounts/MyStorageAccount" + Get-FinOpsCostExport ` + -Scope "/subscriptions/00000000-0000-0000-0000-000000000000" ` + -StorageAccountId "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.Storage/storageAccounts/MyStorageAccount" + ### Get exports using a storage account Gets all exports within the subscription scope filtered by a specific storage account. .EXAMPLE - Get-FinOpsCostExport -Scope "/subscriptions/00000000-0000-0000-0000-000000000000" -StorageContainer "MyContainer*" + Get-FinOpsCostExport ` + -Scope "/subscriptions/00000000-0000-0000-0000-000000000000" ` + -StorageContainer "MyContainer*" + ### Get exports using a storage container Gets all exports within the subscription scope for a specific container. Supports wildcard. .EXAMPLE - Get-FinOpsCostExport -Scope "/subscriptions/00000000-0000-0000-0000-000000000000" -StorageContainer "mtd*" -ApiVersion "2023-07-01-preview" + Get-FinOpsCostExport ` + -Scope "/subscriptions/00000000-0000-0000-0000-000000000000" ` + -StorageContainer "mtd*" ` + -ApiVersion "2023-07-01-preview" + ### Get exports using an API version Gets all exports within the subscription scope for a container matching wildcard pattern and using a specific API version. .LINK @@ -73,7 +95,7 @@ function Get-FinOpsCostExport { param ( - [Parameter()] + [Parameter(Position = 0)] [SupportsWildcards()] [string] $Name, @@ -114,6 +136,7 @@ function Get-FinOpsCostExport { throw $script:LocalizedData.Common_ContextNotFound } + # if Scope is not passed, use current subscription scope if ([System.String]::IsNullOrEmpty($Scope)) { @@ -168,6 +191,34 @@ function Get-FinOpsCostExport $exportdetails = @() $content | ForEach-Object { $item = [PSCustomObject]@{ + # .OUTPUTS FinOpsCostExport + # | Property | Type | JSON path | + # | --------------------- | --------------------- | ---------------------------------------------------------------------------- | + # | `Name` | String | `name` | + # | `Id` | String | `id` | + # | `Type` | String | `type` | + # | `eTag` | String | `eTag` | + # | `Description` | String | `properties.exportDescription` | + # | `Dataset` | String | `properties.definition.type` | + # | `DatasetVersion` | String | `properties.definition.configuration.dataVersion` | + # | `DatasetFilters` | String | `properties.definition.configuration.filter` | + # | `DatasetTimeFrame` | String | `properties.definition.timeframe` | + # | `DatasetStartDate` | DateTime | `properties.definition.timePeriod.from` | + # | `DatasetEndDate` | DateTime | `properties.definition.timePeriod.to` | + # | `DatasetGranularity` | String | `properties.definition.dataset.granularity` | + # | `ScheduleStatus` | String | `properties.schedule.status` | + # | `ScheduleRecurrence` | String | `properties.schedule.recurrence` | + # | `ScheduleStartDate` | DateTime | `properties.schedule.recurrencePeriod.from` | + # | `ScheduleEndDate` | DateTime | `properties.schedule.recurrencePeriod.to` | + # | `NextRuntimeEstimate` | DateTime | `properties.nextRunTimeEstimate` | + # | `Format` | String | `properties.format` | + # | `StorageAccountId` | String | `properties.deliveryInfo.destination.resourceId` | + # | `StorageContainer` | String | `properties.deliveryInfo.destination.container` | + # | `StoragePath` | String | `properties.deliveryInfo.destination.rootfolderpath` | + # | `OverwriteData` | Boolean | `properties.deliveryInfo.dataOverwriteBehavior` == "OverwritePreviousReport" | + # | `PartitionData` | Boolean | `properties.deliveryInfo.partitionData` | + # | `CompressionMode` | String | `properties.deliveryInfo.compressionMode` | + # | `RunHistory` | FinOpsCostExportRun[] | `properties.runHistory.value` | Name = $_.name Id = $_.id Type = $_.type @@ -194,6 +245,17 @@ function Get-FinOpsCostExport CompressionMode = $_.properties.deliveryInfo.compressionMode RunHistory = $_.properties.runHistory.value | Where-Object { $_ -ne $null } | ForEach-Object { [PSCustomObject]@{ + # .OUTPUTS FinOpsCostExportRun + # | Property | Type | JSON path | + # | --------------- | -------- | -------------------------------------------------------- | + # | `Id` | String | `properties.runHistory.value[].id` | + # | `ExecutionType` | String | `properties.runHistory.value[].properties.executionType` | + # | `FileName` | String | `properties.runHistory.value[].fileName` | + # | `StartTime` | DateTime | `properties.runHistory.value[].processingStartTime` | + # | `EndTime` | DateTime | `properties.runHistory.value[].processingEndTime` | + # | `Status` | String | `properties.runHistory.value[].status` | + # | `SubmittedBy` | String | `properties.runHistory.value[].submittedBy` | + # | `SubmittedTime` | DateTime | `properties.runHistory.value[].submittedTime` | Id = $_.id ExecutionType = $_.properties.executionType FileName = $_.fileName diff --git a/src/powershell/Public/Get-FinOpsHub.ps1 b/src/powershell/Public/Get-FinOpsHub.ps1 index 1d3b4f698..084d38aa5 100644 --- a/src/powershell/Public/Get-FinOpsHub.ps1 +++ b/src/powershell/Public/Get-FinOpsHub.ps1 @@ -17,21 +17,25 @@ .EXAMPLE Get-FinOpsHub + ### Get all hubs Returns all FinOps hubs for the selected subscription. .EXAMPLE Get-FinOpsHub -Name foo* + ### Get named hubs Returns all FinOps hubs that start with 'foo'. .EXAMPLE Get-FinOpsHub -ResourceGroupName foo + ### Get hubs in a resource group Returns all resources associated with a FinOps hub in the 'foo' resource group. .EXAMPLE Get-FinOpsHub -Name foo -ResourceGroupName bar + ### Get named hubs in a resource group Returns all FinOps hubs named 'foo' in the 'bar' resource group. .LINK diff --git a/src/powershell/Public/Get-FinOpsPricingUnit.ps1 b/src/powershell/Public/Get-FinOpsPricingUnit.ps1 index c5b70cdb0..d71cfc7d4 100644 --- a/src/powershell/Public/Get-FinOpsPricingUnit.ps1 +++ b/src/powershell/Public/Get-FinOpsPricingUnit.ps1 @@ -5,6 +5,11 @@ .SYNOPSIS Gets a pricing unit with its corresponding distinct unit and block size. + .DESCRIPTION + The Get-FinOpsPricingUnit command returns a pricing unit (aka unit of measure) with the singular, distinct unit based on applicable block pricing rules, and the pricing block size. + + Block pricing is when a service is measured in groups of units (e.g., 100 hours). + .PARAMETER UnitOfMeasure Optional. Unit of measure (aka pricing unit) value from a Cost Management cost/usage details or price sheet dataset. Accepts wildcards. Default = * (all). @@ -14,17 +19,16 @@ .PARAMETER BlockSize Optional. The number of units for block pricing (e.g., 100 for "100 Hours"). Default = null (all). - .DESCRIPTION - The Get-FinOpsPricingUnit command returns a pricing unit (aka unit of measure) with the singular, distinct unit based on applicable block pricing rules, and the pricing block size. - .EXAMPLE Get-FinOpsPricingUnit -UnitOfMeasure "*hours*" + ### Get based on unit of measure Returns all pricing units with "hours" in the name. .EXAMPLE Get-FinOpsPricingUnit -DistinctUnits "GB" + ### Get based on distinct units Returns all pricing units measured in gigabytes. .LINK diff --git a/src/powershell/Public/Get-FinOpsRegion.ps1 b/src/powershell/Public/Get-FinOpsRegion.ps1 index c202a2738..de587f470 100644 --- a/src/powershell/Public/Get-FinOpsRegion.ps1 +++ b/src/powershell/Public/Get-FinOpsRegion.ps1 @@ -3,7 +3,10 @@ <# .SYNOPSIS - Gets an Azure region ID and name. + Gets an Azure region ID and name to clean up Cost Management cost data during ingestion. + + .DESCRIPTION + The Get-FinOpsRegion command returns an Azure region ID and name based on the specified resource location. .PARAMETER ResourceLocation Optional. Resource location value from a Cost Management cost/usage details dataset. Accepts wildcards. Default = * (all). @@ -17,17 +20,16 @@ .PARAMETER IncludeResourceLocation Optional. Indicates whether to include the ResourceLocation property in the output. Default = false. - .DESCRIPTION - The Get-FinOpsRegion command returns an Azure region ID and name based on the specified resource location. - .EXAMPLE Get-FinOpsRegion -ResourceLocation "US East" + ### Get a specific region Returns the region ID and name for the East US region. .EXAMPLE Get-FinOpsRegion -RegionId "*asia*" -IncludeResourceLocation + ### Get many regions with the original Cost Management value Returns all Asia regions with the original Cost Management ResourceLocation value. .LINK diff --git a/src/powershell/Public/Get-FinOpsResourceType.ps1 b/src/powershell/Public/Get-FinOpsResourceType.ps1 index 5a7c740f3..88a42123c 100644 --- a/src/powershell/Public/Get-FinOpsResourceType.ps1 +++ b/src/powershell/Public/Get-FinOpsResourceType.ps1 @@ -17,11 +17,13 @@ .EXAMPLE Get-FinOpsResourceType -ResourceType "microsoft.compute/virtualmachines" + ### Get resource type details Returns the resource type details for virtual machines. .EXAMPLE Get-FinOpsResourceType -Preview $false + ### Get non-preview resource types Returns all resource types that are not in preview. .LINK diff --git a/src/powershell/Public/Get-FinOpsService.ps1 b/src/powershell/Public/Get-FinOpsService.ps1 index f086f9c5d..f4b542bb3 100644 --- a/src/powershell/Public/Get-FinOpsService.ps1 +++ b/src/powershell/Public/Get-FinOpsService.ps1 @@ -5,6 +5,11 @@ .SYNOPSIS Gets the name and category for a service, publisher, and cloud provider. + .DESCRIPTION + The Get-FinOpsService command returns service details based on the specified filters. This command is designed to help map Cost Management cost data to the FinOps Open Cost and Usage Specification (FOCUS) schema but can also be useful for general data cleansing. + + Please note that both ConsumedService and ResourceType are required to find a unique service in many cases. + .PARAMETER ConsumedService Optional. ConsumedService value from a Cost Management cost/usage details dataset. Accepts wildcards. Default = * (all). @@ -32,14 +37,10 @@ .PARAMETER PublisherCategory Optional. The publisher category to find services for. Default = null (all). - .DESCRIPTION - The Get-FinOpsService command returns service details based on the specified filters. This command is designed to help map Cost Management cost data to the FinOps Open Cost and Usage Specification (FOCUS) schema but can also be useful for general data cleansing. - - Please note that both ConsumedService and ResourceType are required to find a unique service in many cases. - .EXAMPLE - Get-FinOpsService -ConsumedService "Microsoft.C*" -ResourceType "Microsoft.Compute/virtualMachines" + Get-FinOpsService -ConsumedService "Microsoft.C*" + ### Get services based on filter Returns all services with a resource provider that starts with "Microsoft.C". .LINK diff --git a/src/powershell/Public/Get-FinOpsToolkitVersion.ps1 b/src/powershell/Public/Get-FinOpsToolkitVersion.ps1 index 5aa2835ad..2f0211a0c 100644 --- a/src/powershell/Public/Get-FinOpsToolkitVersion.ps1 +++ b/src/powershell/Public/Get-FinOpsToolkitVersion.ps1 @@ -6,7 +6,7 @@ Gets available versions from published FinOps toolkit releases. .DESCRIPTION - The Get-FinOpsToolkitVersions command calls GitHub to retrieve all toolkit releases, then filters the list based on the specified options. + The Get-FinOpsToolkitVersion command calls GitHub to retrieve all toolkit releases, then filters the list based on the specified options. .PARAMETER Latest Optional. Indicates that only the most recent release should be returned. Default = false. @@ -17,16 +17,19 @@ .EXAMPLE Get-FinOpsToolkitVersion + ### Get stable release versions Returns all stable (non-preview) release versions. .EXAMPLE Get-FinOpsToolkitVersion -Latest + ### Get latest stable release only Returns only the latest stable (non-preview) release version. .EXAMPLE Get-FinOpsToolkitVersion -Preview + ### Get all versions Returns all release versions, including preview releases. .LINK @@ -35,7 +38,7 @@ function Get-FinOpsToolkitVersion { [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Scope='Function')] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Scope = 'Function')] param ( [Parameter()] diff --git a/src/powershell/Public/Initialize-FinOpsHubDeployment.ps1 b/src/powershell/Public/Initialize-FinOpsHubDeployment.ps1 index 8ca35c2e7..468d24ba0 100644 --- a/src/powershell/Public/Initialize-FinOpsHubDeployment.ps1 +++ b/src/powershell/Public/Initialize-FinOpsHubDeployment.ps1 @@ -5,14 +5,15 @@ .SYNOPSIS Initialize a FinOps hub deployment in order to enable resource group owners to deployment hubs via the portal. + .DESCRIPTION + The Initialize-FinOpsHubDeployment command performs any initialization tasks required for a resource group contributor to be able to deploy a FinOps hub instance in Azure, like registering resource providers. To view the full list of tasks performed, run the command with the -WhatIf option. + .EXAMPLE Initialize-FinOpsHubDeployment -WhatIf + ### Test initialize FinOps hub deployment Shows what would happen if the command runs without actually running it. - .DESCRIPTION - The Initialize-FinOpsHubDeployment command performs any initialization tasks required for a resource group contributor to be able to deploy a FinOps hub instance in Azure, like registering resource providers. To view the full list of tasks performed, run the command with the -WhatIf option. - .LINK https://aka.ms/ftk/Initialize-FinOpsHubDeployment #> diff --git a/src/powershell/Public/New-FinOpsCostExport.ps1 b/src/powershell/Public/New-FinOpsCostExport.ps1 index 0947dc49b..5c9ef59dd 100644 --- a/src/powershell/Public/New-FinOpsCostExport.ps1 +++ b/src/powershell/Public/New-FinOpsCostExport.ps1 @@ -16,13 +16,13 @@ Required. Name of the export. .PARAMETER Scope - Required. Resource ID of the scope to export data for. + Optional. Resource ID of the scope to export data for. If empty, defaults to current subscription context. .PARAMETER Dataset Optional. Dataset to export. Allowed values = "ActualCost", "AmortizedCost", "FocusCost", "PriceSheet", "ReservationDetails", "ReservationTransactions", "ReservationRecommendations". Default = "FocusCost". .PARAMETER DatasetVersion - Optional. Schema version of the dataset to export. Default = "1.0" (applies to FocusCost only). + Optional. Schema version of the dataset to export. Default = (latest version as of June 2024; e.g., "1.0" for FocusCost). .PARAMETER DatasetFilters Optional. Dictionary of key/value pairs to filter the dataset with. Only applies to ReservationRecommendations dataset in 2023-07-01-preview. Valid filters are reservationScope (Shared or Single), resourceType (e.g., VirtualMachines), lookBackPeriod (Last7Days, Last30Days, Last60Days). @@ -67,15 +67,16 @@ Optional. API version to use when calling the Cost Management Exports API. Default = 2023-07-01-preview. .EXAMPLE - New-FinopsCostExport -Name 'July2023OneTime' ` + New-FinopsCostExport -Name 'July2024OneTime' ` -Scope "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ` -StorageAccountId "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/SharedStorage/providers/Microsoft.Storage/storageAccounts/ddsharedstorage" ` -DataSet ActualCost ` -OneTime ` - -StartDate "2023-07-01" ` - -EndDate "2023-07-31" + -StartDate "2024-07-01" ` + -EndDate "2024-07-31" - Creates a new one time export called 'July2023OneTime from 2023-07-01 to 2023-07-31 with Dataset = Actual and execute it once. + ### Create one time export + Creates a new one time export called 'July2024OneTime' from 2024-07-01 to 2024-07-31 with Dataset = Actual and execute it once. .EXAMPLE New-FinopsCostExport -Name 'DailyMTD' ` @@ -85,6 +86,7 @@ -EndDate "2024-12-31" ` -Execute + ### Create and run a daily export Creates a new scheduled export called Daily-MTD with StartDate = DateTime.Now and EndDate = 2024-12-31. Export is run immediately after creation. .EXAMPLE @@ -97,6 +99,7 @@ -Monthly ` -Execute + ### Creates monthly export Creates a new monthly export called Monthly-Report with StartDate = 1 day from DateTime.Now and EndDate 2024-08-15. Export is run immediately after creation. .EXAMPLE @@ -108,6 +111,7 @@ -Backfill 4 ` -Execute + ### Create daily export and backfill 4 months Creates a new daily export called Daily-MTD with StartDate = DateTime.Now and EndDate 5 years from StartDate. Additiionally, export cost data for the previous 4 months and save all results in costreports container of the specified storage account. .LINK @@ -119,11 +123,11 @@ function New-FinOpsCostExport [CmdletBinding(DefaultParameterSetName = "Scheduled")] param ( - [Parameter(Mandatory = $true)] + [Parameter(Mandatory = $true, Position = 0)] [string] $Name, - [Parameter(Mandatory = $true)] + [Parameter(Position = 1)] [string] $Scope, @@ -140,10 +144,12 @@ function New-FinOpsCostExport [hashtable] $DatasetFilters, + # .PARAMETERSET Create a new daily/monthly export [Parameter(ParameterSetName = "Scheduled")] [switch] $Monthly, - + + # .PARAMETERSET Create a new one-time export [Parameter(ParameterSetName = "OneTime")] [switch] $OneTime, @@ -195,6 +201,13 @@ function New-FinOpsCostExport $ApiVersion = '2023-07-01-preview' ) + # if Scope is not passed, use current subscription scope + if ([string]::IsNullOrEmpty($Scope)) + { + $Scope = "/subscriptions/$($context.Subscription.Id)" + Write-Verbose -Message "Scope parameter was not passed. Setting to subscription scope from current context" + } + function getProperties() { # Set default dates based on schedule type diff --git a/src/powershell/Public/Register-FinOpsHubProviders.ps1 b/src/powershell/Public/Register-FinOpsHubProviders.ps1 index 58eb98cc6..c74e48a09 100644 --- a/src/powershell/Public/Register-FinOpsHubProviders.ps1 +++ b/src/powershell/Public/Register-FinOpsHubProviders.ps1 @@ -3,7 +3,12 @@ <# .SYNOPSIS - Registers Azure resource providers required for FinOps hub. + Register Azure resource providers required for FinOps hub. + + .Description + The Register-FinOpsHubProviders command registers the Azure resource providers required to deploy and operate a FinOps hub instance. + + To register a resource provider, you must have Contributor access (or the /register permission for each resource provider) for the entire subscription. Subscription readers can check the status of the resource providers but cannot register them. If you do not have access to register resource providers, please contact a subscription contributor or owner to run the Register-FinOpsHubProviders command. .PARAMETER WhatIf Optional. Shows what would happen if the command runs without actually running it. @@ -12,9 +17,6 @@ Register-FinOpsHubProviders -WhatIf Shows what would happen if the command runs without actually running it. - - .Description - The Register-FinOpsHubProviders command registers the Azure resource providers required to deploy and operate a FinOps hub instance. To register a resource provider, you must have Contributor access (or the /register permission for each resource provider) for the entire subscription. Subscription readers can check the status of the resource providers but cannot register them. If you do not have access to register resource providers, please contact a subscription contributor or owner to run the Register-FinOpsHubProviders command. #> function Register-FinOpsHubProviders { diff --git a/src/powershell/Public/Remove-FinOpsCostExport.ps1 b/src/powershell/Public/Remove-FinOpsCostExport.ps1 index e99cb04fc..65256baeb 100644 --- a/src/powershell/Public/Remove-FinOpsCostExport.ps1 +++ b/src/powershell/Public/Remove-FinOpsCostExport.ps1 @@ -14,7 +14,7 @@ - 2023-03-01 .PARAMETER Name - Name of the Cost Management export. + Required. Name of the Cost Management export to delete. .PARAMETER Scope Required. Resource ID of the scope to export data for. @@ -22,13 +22,17 @@ .PARAMETER RemoveData Optional. Indicates that all cost data associated with the Export scope should be deleted. - .PARAMETER APIVersion + .PARAMETER ApiVersion Optional. API version to use when calling the Cost Management Exports API. Default = 2023-07-01-preview. - + .EXAMPLE - Remove-FinOpsCostExport -Name MyExport -Scope "/subscriptions/00000000-0000-0000-0000-000000000000" -RemoveData + Remove-FinOpsCostExport ` + -Name MyExport ` + -Scope "/subscriptions/00000000-0000-0000-0000-000000000000" ` + -RemoveData - Deletes a Cost Management export named MyExport scoped to /subscriptions/00000000-0000-0000-0000-000000000000, and deletes all exported data from the related storage account. + ### Delete a Cost Management export + Deletes a Cost Management export and deletes all exported data from the related storage account. #> function Remove-FinOpsCostExport diff --git a/src/powershell/Public/Remove-FinOpsHub.ps1 b/src/powershell/Public/Remove-FinOpsHub.ps1 index 92f256572..5eefdafda 100644 --- a/src/powershell/Public/Remove-FinOpsHub.ps1 +++ b/src/powershell/Public/Remove-FinOpsHub.ps1 @@ -11,21 +11,28 @@ The comamnd returns a boolean value indicating whether all resources were successfully deleted. .PARAMETER Name - Required when specifying Name. Name of the FinOps Hub. + Required if not specifying InputObject. Name of the FinOps hub instance. .PARAMETER ResourceGroupName - Optional when specifying Name. Resource Group Name for the FinOps Hub. + Optional when specifying Name. Resource group name for the FinOps Hub. .PARAMETER InputObject - Required when specifying InputObject. Expected object is the output of Get-FinOpsHub. + Required if not specifying Name. Expected object is the output of Get-FinOpsHub. .PARAMETER KeepStorageAccount - Optional. Indicates that the storage account associated with the FinOps Hub should be retained. + Optional. Indicates that the storage account associated with the FinOps Hub should be retained. Default = false. + + .PARAMETER Force + Optional. Indicates that the hub instance should be deleted without an additional confirmation. Default = false. .EXAMPLE - Remove-FinOpsHub -Name MyHub -ResourceGroupName MyRG -KeepStorageAccount + Remove-FinOpsHub ` + -Name MyHub ` + -ResourceGroupName MyRG ` + -KeepStorageAccount - Deletes a FinOps Hub named MyHub and deletes all associated resource except the storagea ccount. + ### Remove a FinOps hub instance + Deletes a FinOps Hub named MyHub and deletes all associated resource except the storage account. #> function Remove-FinOpsHub @@ -38,10 +45,12 @@ function Remove-FinOpsHub [string] $Name, + # .PARAMETERSET Delete by name [Parameter(ParameterSetName = 'Name')] [string] $ResourceGroupName, - + + # .PARAMETERSET Delete by reference [Parameter(Mandatory = $true, ParameterSetName = 'Object')] [ValidateNotNullOrEmpty ()] [psobject] diff --git a/src/powershell/Public/Remove-FinOpsHubScope.ps1 b/src/powershell/Public/Remove-FinOpsHubScope.ps1 index a55995007..78c586463 100644 --- a/src/powershell/Public/Remove-FinOpsHubScope.ps1 +++ b/src/powershell/Public/Remove-FinOpsHubScope.ps1 @@ -23,11 +23,13 @@ .EXAMPLE Remove-FinOpsHubScope -Id "/providers/Microsoft.Billing/billingAccounts/123" -HubName "FooHub" + ### Remove billing account and keep data Deletes the exports configured to use the FooHub hub instance. Existing data is retained in the storage account. .EXAMPLE Remove-FinOpsHubScope -Id "/subscriptions/##-#-#-#-###" -HubName "FooHub" -RemoveData + ### Remove subscription and historical data Deletes the exports configured to use the FooHub hub instance and removes data for that scope. .LINK diff --git a/src/powershell/Public/Start-FinOpsCostExport.ps1 b/src/powershell/Public/Start-FinOpsCostExport.ps1 index 1c4c35b47..d45777134 100644 --- a/src/powershell/Public/Start-FinOpsCostExport.ps1 +++ b/src/powershell/Public/Start-FinOpsCostExport.ps1 @@ -34,16 +34,19 @@ .EXAMPLE Start-FinopsCostExport -Name 'CostExport' + ### Export configured period Runs an export called 'CostExport' for the configured period. .EXAMPLE Start-FinopsCostExport -Name 'CostExport' -StartDate '2023-01-01' -EndDate '2023-12-31' + ### Export specific dates Runs an export called 'CostExport' for a specific date range. .EXAMPLE Start-FinopsCostExport -Name 'CostExport' -Backfill 12 + ### Backfill export Runs an export called 'CostExport' for the previous 12 months. .LINK @@ -54,11 +57,11 @@ function Start-FinOpsCostExport [cmdletBinding()] param ( - [Parameter(Mandatory = $true)] + [Parameter(Mandatory = $true, Position = 0)] [string] $Name, - [Parameter()] + [Parameter(Position = 1)] [string] $Scope, @@ -201,6 +204,7 @@ function Start-FinOpsCostExport Write-Progress ` -Activity $progressActivity ` -Status "$percent% complete - Throttled by Cost Management. Waiting 60 seconds." ` + } else { diff --git a/src/scripts/Build-Documentation.ps1 b/src/scripts/Build-Documentation.ps1 new file mode 100644 index 000000000..767fd00eb --- /dev/null +++ b/src/scripts/Build-Documentation.ps1 @@ -0,0 +1,259 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +<# + .SYNOPSIS + Generates automated documentation for applicable tools. + + .PARAMETER Command + Optional. PowerShell command to generate documentation for. Default = * (all). + + .EXAMPLE + ./Build-Documentation + + ### Generate documentation + Generates documentation for all applicable tools. + + .LINK + https://github.com/microsoft/finops-toolkit/blob/dev/src/scripts/README.md#-build-documentation +#> +[CmdletBinding()] +Param( + [string] + $Command = '*' +) + +$Debug = $DebugPreference -eq "Continue" + +$srcDir = "$PSScriptRoot/../" +$docDir = "$PSScriptRoot/../../docs/" +$psDocs = "$docDir/_automation/powershell/" + +# Generate PowerShell docs +Write-Host "Generating PowerShell documentation..." +Get-ChildItem -Path "$srcDir/powershell/Public/$Command.ps1" ` +| ForEach-Object { + $file = $_ + $commandName = $_.BaseName + $noun = $commandName.Split('-FinOps')[1] + + Write-Host "- $commandName" + + # TODO: Validate PowerShell commands have required help content + # TODO: Validated the relatedLinks.navigationLink.uri is set and resolves correctly + + # Map commands to folders + if ($noun.StartsWith('Cost')) + { + $navParent = 'Cost Management' + $folder = 'cost' + $tools = 'aoe="1" bicep="0" data="0" hubs="1" pbi="1" ps="0"' + } + elseif ($noun.StartsWith('Hub')) + { + $navParent = 'FinOps hubs' + $folder = 'hubs' + $tools = 'aoe="1" bicep="0" data="0" hubs="1" pbi="1" ps="0"' + } + elseif (@('PricingUnit', 'Region', 'ResourceType', 'Service') -contains $noun) + { + $navParent = 'Open data' + $folder = 'data' + $tools = 'aoe="0" bicep="0" data="1" hubs="1" pbi="1" ps="0"' + } + else + { + $navParent = 'Toolkit' + $folder = 'toolkit' + $tools = 'aoe="1" bicep="0" hubs="1" wb="1" pbi="1" ps="0"' + } + + # Load the script inline to get help content (since they are functions in each file) + # TODO: Would it be better to just load the latest module version and use that? + & { + . $file + $script:helpOutput = Get-Help $commandName -Full + } + $psDoc = $script:helpOutput + $psTxt = Get-Content $file + + # Collect file contents via string builder for perf + $sb = [System.Text.StringBuilder]::new() + function append([string] $Text, [switch] $NoNewLine) + { + if ($NoNewLine) { [void]$sb.Append($Text) } else { [void]$sb.AppendLine($Text) } + } + + # Check if the command has a documented Confirm parameter so we can hide it when not applicable + $hasConfirm = ($psDoc.Parameters.Parameter | Where-Object { $_.Name -eq 'Confirm' -and [string]::Join($_.Description.Text, '').Length -gt 0 }).Count -gt 0 + + append '---' + append "layout: default" + append "grand_parent: PowerShell" + append "parent: $navParent" + append "title: $commandName" + append "nav_order: 10" # All commands are 10 to save room for any higher priority content + append "description: $($psDoc.Synopsis)" + append "permalink: /powershell/$folder/$commandName" + append '---' + append '' + append "$commandName" + append $psDoc.Synopsis + append '{: .fs-6 .fw-300 }' + append '' + append '[Syntax](#-syntax){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-4 }' + append '[Examples](#-examples){: .btn .fs-5 .mb-4 .mb-md-0 .mr-4 }' + append '' + append '
' + append ' On this page' + append '' + append '- [🧮 Syntax](#-syntax)' + append '- [📥 Parameters](#-parameters)' + if ($psDoc.ReturnValues) + { + append '- [📤 Return value](#-return-value)' + } + append '- [🌟 Examples](#-examples)' + append '- [🧰 Related tools](#-related-tools)' + append '' + append '
' + append '' + append '---' + append '' + $commandDesc = ($psDoc.Description.Text | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }) -join "`n`n" + $commandDesc = [regex]::Replace($commandDesc, "(([A-Z][a-z]+)-FinOps([A-Za-z]+))", "[`$1](`$1.md)") + $commandDesc = $commandDesc.Replace("[$commandName]($commandName.md)", "$commandName") + if ($commandDesc) + { + $commandDescLines = $commandDesc.Split("`n") + append ([regex]::Replace($commandDescLines[0], "(?' + append '' + } + append '## 🧮 Syntax' + append '' + $paramSets = $psTxt | Select-String -Pattern '#\s+\.PARAMETERSET\s+(.*)$' | ForEach-Object { $_.Matches.Groups[1].Value } + $paramSetIndex = 0 + $psDoc.Syntax.SyntaxItem ` + | ForEach-Object { + append '```powershell' + if ($paramSets.Length -gt $paramSetIndex) + { + append "# $($paramSets[$paramSetIndex++])" + } + append "$($_.Name)" -NoNewLine # Do not end the line yet + $_.Parameter ` + | Where-Object { $_.Name -ne 'Confirm' -or $hasConfirm } + | ForEach-Object { + $parameter = $_ + append ' `' + append ' ' -NoNewLine + if ($parameter.Required -ne $true) { append '[' -NoNewLine } + if ($parameter.Position -ne 'named') { append '[' -NoNewLine } + append "‑$($parameter.Name)" -NoNewLine + if ($parameter.Position -ne 'named') { append ']' -NoNewLine } + if ($parameter.ParameterValue.Length -gt 0) { append " <$($parameter.ParameterValue)>" -NoNewLine } + if ($parameter.Required -ne $true) { append ']' -NoNewLine } + if ($Debug) { append " -- REQ: $($parameter.Required), POS: $($parameter.Position)" -NoNewLine } + # TODO: defaultValue?, globbing, pipelineInput + } + append '' # Write an extra line to end the previous line (because of -NoNewLine) + append '```' + append '' + } + append '
' + append '' + append '## 📥 Parameters' + append '' + append '| Name | Description |' + append '| ---- | ----------- |' + $psDoc.Parameters.Parameter ` + | Where-Object { $_.Name -ne 'Confirm' -or $hasConfirm } + | ForEach-Object { + $parameter = $_ + $desc = (($parameter.Description.Text | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }) + '').Replace("`n", "
") -join "

" + if ($parameter.Name -eq 'WhatIf' -and [string]::IsNullOrWhiteSpace($desc)) + { + $desc = 'Optional. Shows what would happen if the command runs without actually running the command. Default = false.' + } + append "| ``‑$($parameter.Name)`` | $desc |" + } + append '' + if ($Debug) { append ($psDoc.Parameters | ConvertTo-Json -Depth 20) } + append '
' + append '' + if ($psDoc.ReturnValues) + { + append '## 📤 Return value' + append '' + $linePrefix = $null + $psTxt | ForEach-Object { + $line = $_ + if ($line -match '# .OUTPUTS') + { + $typeDef = $line.Split('.OUTPUTS') + $linePrefix = $typeDef[0] + $returnType = $typeDef[1].Trim() + append "### $returnType object" + append '' + } + elseif ($linePrefix -and $line.StartsWith($linePrefix)) + { + append $line.Replace($linePrefix, '') + } + elseif ($linePrefix -and $line.StartsWith($linePrefix) -eq $false) + { + $linePrefix = $null + append '' + } + } + append '
' + append '' + } + append '## 🌟 Examples' + append '' + $psDoc.Examples.Example ` + | ForEach-Object { + $example = $_ + $desc = ($example.Remarks.Text | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }) -join '

' + if ($desc.StartsWith("### ")) + { + $title = $desc.Substring(0, $desc.IndexOf("`n")) + $desc = $desc.Substring($title.Length + 1) + } + else + { + $title = $example.Title.Replace('-', '').Trim(' ').Replace('EXAMPLE', '### Example') + } + append $title + append '' + append '```powershell' + append $example.Code + append '```' + append '' + append $desc + append '' + } + append '
' + append '' + append '---' + append '' + append "## 🧰 Related tools" + append '' + append "{% include tools.md $tools %}" + append '' + append '
' + if ($Debug) { append ($psDoc | ConvertTo-Json -Depth 100) } + + $sb.Tostring() | Out-File "$psDocs/$folder/$commandName.md" -Force -Encoding 'UTF8' + $sb.Clear() | Out-Null +} diff --git a/src/scripts/Deploy-Toolkit.ps1 b/src/scripts/Deploy-Toolkit.ps1 index 4aa18c3ab..8b17e85f8 100644 --- a/src/scripts/Deploy-Toolkit.ps1 +++ b/src/scripts/Deploy-Toolkit.ps1 @@ -8,11 +8,13 @@ .EXAMPLE Deploy-Toolkit "finops-hub" + ### Deploy tool Deploys a new FinOps hub instance. .EXAMPLE Deploy-Toolkit -WhatIf - + + ### Validate deployment Validates the deployment template or module without changing resources. .PARAMETER Template @@ -56,28 +58,34 @@ Param( # Use the debug flag from common parameters to determine whether to run in debug mode $Debug = $DebugPreference -eq "Continue" -function iff([bool]$Condition, $IfTrue, $IfFalse) { +function iff([bool]$Condition, $IfTrue, $IfFalse) +{ if ($Condition) { $IfTrue } else { $IfFalse } } # Build toolkit if requested -if ($Build) { +if ($Build) +{ & "$PSScriptRoot/Build-Toolkit" -Template $Template # NOTE: Include templates after release to account for test templates, which are not included in release builds $templateFolders = @("$PSScriptRoot/../../release", "$PSScriptRoot/../templates") -} else { +} +else +{ # NOTE: Do not include the workbooks folder since they must be built first; they're included in the release folder $templateFolders = @("$PSScriptRoot/../templates", "$PSScriptRoot/../bicep-registry", "$PSScriptRoot/../../release") } # Don't run test and demo deployment at the same time -if ($Test -and $Demo) { +if ($Test -and $Demo) +{ Write-Error "Cannot specify both -Test and -Demo. Please try again." return } # Generates a unique name based on the signed in username and computer name for local testing -function Get-UniqueName() { +function Get-UniqueName() +{ # NOTE: For some reason, using variables directly does not get the value until we write them $c = $env:ComputerName $u = $env:USERNAME @@ -97,7 +105,8 @@ $defaultParameters = @{ $global:ftkDeployment = $null # If deploying a workbook, switch to the release folder name -if (Test-Path "$PSScriptRoot/../workbooks/$Template") { +if (Test-Path "$PSScriptRoot/../workbooks/$Template") +{ $Template = "$Template-workbook" } @@ -115,14 +124,19 @@ $templateFolders ` $Parameters = iff ($null -eq $Parameters) @{} $Parameters Write-Host "Deploying $templateName (from $parentFolder)..." - switch ($targetScope) { - "resourceGroup" { + switch ($targetScope) + { + "resourceGroup" + { # Set default RG name - if ($Demo) { + if ($Demo) + { # Use "FinOps-Toolkit-Demo" for the demo $ResourceGroup = "FinOps-Toolkit-Demo" - } elseif ([string]::IsNullOrEmpty($ResourceGroup)) { + } + elseif ([string]::IsNullOrEmpty($ResourceGroup)) + { # Use "ftk--" for local testing $ResourceGroup = Get-UniqueName } @@ -130,12 +144,16 @@ $templateFolders ` Write-Host " → [rg] $ResourceGroup..." $Parameters.Keys | ForEach-Object { Write-Host " $($_) = $($Parameters[$_])" } - if ($Debug) { + if ($Debug) + { Write-Host " $templateFile" - } else { + } + else + { # Create resource group if it doesn't exist $rg = Get-AzResourceGroup $ResourceGroup -ErrorAction SilentlyContinue - If ($null -eq $rg) { + If ($null -eq $rg) + { New-AzResourceGroup ` -Name $ResourceGroup ` -Location $Location ` @@ -154,14 +172,18 @@ $templateFolders ` return "https://portal.azure.com/#resource/subscriptions/$((Get-AzContext).Subscription.Id)/resourceGroups/$ResourceGroup" } - "subscription" { + "subscription" + { Write-Host " → [sub] $((Get-AzContext).Subscription.Name)..." $Parameters.Keys | ForEach-Object { Write-Host " $($_) = $($Parameters[$_])" } - if ($Debug) { + if ($Debug) + { Write-Host " $templateFile" - } else { + } + else + { $global:ftkDeployment = New-AzSubscriptionDeployment ` -TemplateFile $templateFile ` -TemplateParameterObject $Parameters ` @@ -173,18 +195,23 @@ $templateFolders ` return "https://portal.azure.com/#resource/subscriptions/$((Get-AzContext).Subscription.Id)" } - "managementGroup" { + "managementGroup" + { Write-Error "Management group deployments have not been implemented yet" } - "tenant" { + "tenant" + { $azContext = (Get-AzContext).Tenant Write-Host " → [tenant] $(iff ([string]::IsNullOrWhitespace($azContext.Name)) $azContext.Id $azContext.Name)..." $Parameters.Keys | ForEach-Object { Write-Host " $($_) = $($Parameters[$_])" } - if ($Debug) { + if ($Debug) + { Write-Host " $templateFile" - } else { + } + else + { $global:ftkDeployment = New-AzTenantDeployment ` -TemplateFile $templateFile ` -TemplateParameterObject $Parameters `