Skip to content

Commit c0854d7

Browse files
authored
Merge branch 'develop' into Update-FabricCapacity-161
2 parents 16fde29 + d467af3 commit c0854d7

30 files changed

+147
-134
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
### Changed
1414

1515
- Version of `Microsoft.PowerShell.PSResourceGet` and `Microsoft.PowerShell.PlatyPS` updated
16+
- Replace the repo's configuration approach with PSFramework (move config handling to PSFramework) #85
17+
- Applied `Invoke-FabricRestMethod` to several public cmdlets #85
1618

1719
### Fixed
1820

21+
- Fixed bug in `Update-FabricSemanticModelDefinition` - Uri was incorrect when a platform file exists
22+
1923
### Deprecated
2024

2125
### Removed

RequiredModules.psd1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
#}
1414
Assert = "0.9.6"
1515
InvokeBuild = 'latest'
16-
PSScriptAnalyzer = '1.19.1'
16+
PSScriptAnalyzer = '1.24.0'
1717
Pester = 'latest'
1818
ModuleBuilder = 'latest'
1919
ChangelogManagement = 'latest'
2020
Sampler = 'latest'
2121
'Sampler.GitHubTasks' = 'latest'
2222
MarkdownLinkCheck = 'latest'
23-
PSFramework = 'latest'
24-
'Az.Accounts' = '5.0.0'
25-
'Az.Resources' = '6.15.1'
23+
'PSFramework' = 'latest'
24+
'Az.Accounts' = '5.3.0'
25+
'Az.Resources' = '8.1.1'
2626
'MicrosoftPowerBIMgmt' = '1.2.1111'
2727
'Microsoft.PowerShell.PlatyPS' = 'latest'
2828
}

build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Pester:
103103
# - FunctionalQuality
104104
# - TestQuality
105105
Tag:
106-
CodeCoverageThreshold: 0.30 # 85 # Set to 0 to bypass
106+
CodeCoverageThreshold: 0.10 # 85 # Set to 0 to bypass
107107
#CodeCoverageOutputFile: JaCoCo_$OsShortName.xml
108108
#CodeCoverageOutputFileEncoding: ascii
109109
# Use this if code coverage should be merged from several pipeline test jobs.

docs/en-US/FabricTools.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Retrieves the workloads for a specific capacity.
112112

113113
### [Get-FabricConfig](Get-FabricConfig.md)
114114

115-
Gets the configuration for use with all functions in the PSFabricTools module.
115+
Gets the configuration for use with all functions in the FabricTools module.
116116

117117
### [Get-FabricConnection](Get-FabricConnection.md)
118118

@@ -686,7 +686,7 @@ Retrieves External Data Shares details from a specified Microsoft Fabric.
686686

687687
### [Set-FabricConfig](Set-FabricConfig.md)
688688

689-
Register the configuration for use with all functions in the PSFabricTools module.
689+
Register the configuration for use with all functions in the FabricTools module.
690690

691691
### [Start-FabricDeploymentPipelineStage](Start-FabricDeploymentPipelineStage.md)
692692

@@ -875,4 +875,3 @@ Updates the role assignment for a specific principal in a Fabric workspace.
875875
### [Write-FabricLakehouseTableData](Write-FabricLakehouseTableData.md)
876876

877877
Loads data into a specified table in a Lakehouse within a Fabric workspace.
878-

docs/en-US/Get-FabricConfig.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ title: Get-FabricConfig
1313

1414
## SYNOPSIS
1515

16-
Gets the configuration for use with all functions in the PSFabricTools module.
16+
Gets the configuration for use with all functions in the FabricTools module.
1717

1818
## SYNTAX
1919

@@ -27,21 +27,21 @@ Get-FabricConfig [[-ConfigName] <string>]
2727

2828
## DESCRIPTION
2929

30-
Gets the configuration for use with all functions in the PSFabricTools module.
30+
Gets the configuration for use with all functions in the FabricTools module.
3131

3232
## EXAMPLES
3333

3434
### EXAMPLE 1
3535

36-
Gets all configuration values for the PSFabricTools module and outputs them.
36+
Gets all configuration values for the FabricTools module and outputs them.
3737

3838
```powershell
3939
Get-FabricConfig
4040
```
4141

4242
### EXAMPLE 2
4343

44-
Gets the BaseUrl configuration value for the PSFabricTools module.
44+
Gets the BaseUrl configuration value for the FabricTools module.
4545

4646
```powershell
4747
Get-FabricConfig -ConfigName BaseUrl
@@ -81,4 +81,3 @@ Author: Jess Pomfret
8181
## RELATED LINKS
8282
8383
{{ Fill in the related links here }}
84-

docs/en-US/Set-FabricConfig.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ title: Set-FabricConfig
1313

1414
## SYNOPSIS
1515

16-
Register the configuration for use with all functions in the PSFabricTools module.
16+
Register the configuration for use with all functions in the FabricTools module.
1717

1818
## SYNTAX
1919

@@ -28,21 +28,21 @@ Set-FabricConfig [[-WorkspaceGUID] <guid>] [[-DataWarehouseGUID] <guid>] [[-Base
2828

2929
## DESCRIPTION
3030

31-
Register the configuration for use with all functions in the PSFabricTools module.
31+
Register the configuration for use with all functions in the FabricTools module.
3232

3333
## EXAMPLES
3434

3535
### EXAMPLE 1
3636

37-
Registers the specified Fabric Data Warehouse configuration for use with all functions in the PSFabricTools module.
37+
Registers the specified Fabric Data Warehouse configuration for use with all functions in the FabricTools module.
3838

3939
```powershell
4040
Set-FabricConfig -WorkspaceGUID 'GUID-GUID-GUID-GUID' -DataWarehouseGUID 'GUID-GUID-GUID-GUID'
4141
```
4242

4343
### EXAMPLE 2
4444

45-
Registers the specified Fabric Data Warehouse configuration for use with all functions in the PSFabricTools module, but does not persist the values.
45+
Registers the specified Fabric Data Warehouse configuration for use with all functions in the FabricTools module, but does not persist the values.
4646

4747
```powershell
4848
Set-FabricConfig -WorkspaceGUID 'GUID-GUID-GUID-GUID' -DataWarehouseGUID 'GUID-GUID-GUID-GUID' -SkipPersist
@@ -196,4 +196,3 @@ Author: Jess Pomfret
196196
## RELATED LINKS
197197
198198
{{ Fill in the related links here }}
199-

source/Private/Confirm-TokenState.ps1

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,32 @@ function Confirm-TokenState {
2424
[CmdletBinding()]
2525
param ()
2626

27+
# Refresh the global FabricConfig variable to be backwards compatible
28+
$script:FabricConfig = Get-PSFConfigValue 'FabricTools.FabricApi.BaseApiUrl'
29+
2730
Write-Message -Message "Validating token..." -Level Verbose
2831

2932
try {
3033
# Ensure required properties have valid values
31-
if ([string]::IsNullOrWhiteSpace($FabricConfig.TenantId) -or
32-
[string]::IsNullOrWhiteSpace($FabricConfig.TokenExpiresOn)) {
34+
$tenantId = Get-PSFConfigValue FabricTools.FabricApi.TenantId
35+
$tokenExpiresOn = Get-PSFConfigValue FabricTools.FabricSession.TokenExpiresOn
36+
37+
if ([string]::IsNullOrWhiteSpace($tenantId) -or
38+
[string]::IsNullOrWhiteSpace($tokenExpiresOn)) {
3339
Write-Message -Message "Token details are missing. Please run 'Connect-FabricAccount' to configure the session." -Level Error
3440
throw "MissingTokenDetailsException: Token details are missing."
3541
}
3642

3743
# Convert the TokenExpiresOn value to a DateTime object
38-
if ($FabricConfig.TokenExpiresOn.GetType() -eq [datetimeoffset]) {
39-
$tokenExpiryDate = $FabricConfig.TokenExpiresOn
44+
if ($tokenExpiresOn.GetType() -eq [DateTimeOffset]) {
45+
$tokenExpiryDate = $tokenExpiresOn
4046
} else {
41-
$tokenExpiryDate = [datetimeoffset]::Parse($FabricConfig.TokenExpiresOn)
47+
$tokenExpiryDate = [DateTimeOffset]::Parse($tokenExpiresOn)
4248
}
4349

4450
# Check if the token is expired
45-
if ($tokenExpiryDate -le [datetimeoffset]::Now) {
46-
if ($FabricConfig.FeatureFlags.EnableTokenRefresh) {
51+
if ($tokenExpiryDate -le [DateTimeOffset]::Now) {
52+
if (Get-PSFConfigValue -FullName 'FabricTools.FeatureFlags.EnableTokenRefresh') {
4753
Write-Message -Message "Token has expired. Attempting to refresh the token..." -Level Warning
4854
Connect-FabricAccount -reset
4955
} else {

source/Private/Set-FabConfig.ps1

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,24 @@
1-
# this is a workaround to get the variables set for now
2-
# TODO: change to use PSFConfig?
1+
Set-PSFConfig -Name 'FabricTools.FabricApi.BaseApiUrl' -Value 'https://api.fabric.microsoft.com/v1'
2+
Set-PSFConfig -Name 'FabricTools.FabricApi.ResourceUrl' -Value 'https://api.fabric.microsoft.com'
3+
Set-PSFConfig -Name 'FabricTools.FabricApi.TenantId'
4+
Set-PSFConfig -Name 'FabricTools.FabricApi.ContentType' -Value 'application/json; charset=utf-8'
35

4-
$script:FabricSession = [ordered]@{
5-
BaseApiUrl = 'https://api.fabric.microsoft.com/v1'
6-
ResourceUrl = 'https://api.fabric.microsoft.com'
7-
HeaderParams = $null
8-
ContentType = @{'Content-Type' = "application/json" }
9-
KustoURL = "https://api.kusto.windows.net"
10-
AccessToken = $null
11-
}
6+
Set-PSFConfig -Name 'FabricTools.FabricSession.Headers' -Value @{}
7+
Set-PSFConfig -Name 'FabricTools.FabricSession.TokenExpiresOn' -Value $null
8+
Set-PSFConfig -Name 'FabricTools.FabricSession.AccessToken' -Value $null
129

13-
$script:AzureSession = [ordered]@{
14-
BaseApiUrl = "https://management.azure.com"
15-
AccessToken = $null
16-
HeaderParams = $null
17-
}
10+
Set-PSFConfig -Name 'FabricTools.KustoApi.BaseUrl' -Value 'https://api.kusto.windows.net'
11+
Set-PSFConfig -Name 'FabricTools.AzureApi.BaseUrl' -Value "https://management.azure.com"
1812

19-
$script:PowerBI = [ordered]@{
20-
BaseApiUrl = "https://api.powerbi.com/v1.0/myorg"
21-
}
13+
Set-PSFConfig -Name 'FabricTools.AzureSession.AccessToken' -Value $null
14+
Set-PSFConfig -Name 'FabricTools.AzureSession.Headers' -Value @{}
2215

23-
$FabricConfig = @{
16+
Set-PSFConfig -Name 'FabricTools.PowerBiApi.BaseUrl' -Value "https://api.powerbi.com/v1.0/myorg"
17+
18+
# Remain backwards compatible with scripts relying on $FabricConfig variable
19+
$script:FabricConfig = @{
2420
BaseUrl = "https://api.fabric.microsoft.com/v1"
25-
ResourceUrl = "https://api.fabric.microsoft.com"
26-
FabricHeaders = @{}
27-
TenantId = ""
28-
TokenExpiresOn = ""
29-
FeatureFlags = @{
30-
EnableTokenRefresh = $true
31-
}
3221
}
22+
23+
# Feature Flags
24+
Set-PSFConfig -Name 'FabricTools.FeatureFlags.EnableTokenRefresh' -Value $true -Validation bool

source/Public/Capacity/Get-FabricCapacityRefreshables.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ Author: Ioana Bouariu
3636

3737
# Make a GET request to the PowerBI API to retrieve the top refreshable capacities.
3838
# The function returns the 'value' property of the response.
39-
return (Invoke-RestMethod -uri "$($PowerBI.BaseApiUrl)/capacities/refreshables?`$top=$top" -Headers $FabricSession.HeaderParams -Method GET).value
39+
$result = Invoke-FabricRestMethod -Method GET -PowerBIApi -Uri "capacities/refreshables?`$top=$top"
40+
$result.value
4041
}

source/Public/Capacity/Get-FabricCapacitySkus.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ Author: Kamil Nowinski
3939

4040
Confirm-TokenState
4141

42+
$AzureBaseApiUrl = Get-PSFConfigValue 'FabricTools.AzureApi.BaseUrl'
43+
$AzureSessionHeaderParams = Get-PSFConfigValue 'FabricTools.AzureSession.Headers'
44+
4245
#GET https://management.azure.com/subscriptions/548B7FB7-3B2A-4F46-BB02-66473F1FC22C/resourceGroups/TestRG/providers/Microsoft.Fabric/capacities/azsdktest/skus?api-version=2023-11-01
43-
$uri = "$($AzureSession.BaseApiUrl)/subscriptions/$subscriptionID/resourceGroups/$ResourceGroupName/providers/Microsoft.Fabric/capacities/$capacity/skus?api-version=2023-11-01"
44-
$result = Invoke-RestMethod -Headers $AzureSession.HeaderParams -Uri $uri -Method GET
46+
$uri = "$AzureBaseApiUrl/subscriptions/$subscriptionID/resourceGroups/$ResourceGroupName/providers/Microsoft.Fabric/capacities/$capacity/skus?api-version=2023-11-01"
47+
$result = Invoke-RestMethod -Headers $AzureSessionHeaderParams -Uri $uri -Method GET
4548

4649
return $result.value
4750

0 commit comments

Comments
 (0)