Skip to content

Commit a53f15d

Browse files
authored
Merge pull request #176 from dataplat/bug_fabric_connection
Fixed the bug related to session configs after recent changes to PsFabricConfig
2 parents 0510ec6 + ab606a5 commit a53f15d

6 files changed

Lines changed: 20 additions & 15 deletions

File tree

source/Private/Confirm-TokenState.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function Confirm-TokenState {
2525
param ()
2626

2727
# Refresh the global FabricConfig variable to be backwards compatible
28-
$script:FabricConfig = Get-PSFConfigValue 'FabricTools.FabricApi.BaseApiUrl'
28+
$script:FabricConfig.BaseUrl = Get-PSFConfigValue 'FabricTools.FabricApi.BaseUrl'
2929

3030
Write-Message -Message "Validating token..." -Level Verbose
3131

source/Private/Set-FabConfig.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Set-PSFConfig -Name 'FabricTools.FabricApi.BaseApiUrl' -Value 'https://api.fabric.microsoft.com/v1'
1+
Write-Verbose "Setting FabricTools configuration defaults..."
2+
3+
Set-PSFConfig -Name 'FabricTools.FabricApi.BaseUrl' -Value 'https://api.fabric.microsoft.com/v1'
24
Set-PSFConfig -Name 'FabricTools.FabricApi.ResourceUrl' -Value 'https://api.fabric.microsoft.com'
35
Set-PSFConfig -Name 'FabricTools.FabricApi.TenantId'
46
Set-PSFConfig -Name 'FabricTools.FabricApi.ContentType' -Value 'application/json; charset=utf-8'

source/Public/Capacity/Get-FabricCapacityState.ps1

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ Retrieves the state of a specific capacity.
66
.DESCRIPTION
77
The Get-FabricCapacityState function retrieves the state of a specific capacity. It supports multiple aliases for flexibility.
88
9-
.PARAMETER subscriptionID
9+
.PARAMETER SubscriptionID
1010
The ID of the subscription. This is a mandatory parameter. This is a parameter found in Azure, not Fabric.
1111
12-
.PARAMETER resourcegroup
12+
.PARAMETER ResourceGroup
1313
The resource group. This is a mandatory parameter. This is a parameter found in Azure, not Fabric.
1414
15-
.PARAMETER capacity
15+
.PARAMETER Capacity
1616
The capacity. This is a mandatory parameter. This is a parameter found in Azure, not Fabric.
1717
1818
.EXAMPLE
1919
This example retrieves the state of a specific capacity given the subscription ID, resource group, and capacity.
2020
2121
```powershell
22-
Get-FabricCapacityState -subscriptionID "your-subscription-id" -resourcegroupID "your-resource-group" -capacityID "your-capacity"
22+
Get-FabricCapacityState -SubscriptionID "your-subscription-id" -ResourceGroup "your-resource-group" -Capacity "your-capacity"
2323
```
2424
2525
.NOTES
@@ -36,20 +36,21 @@ Author: Ioana Bouariu
3636
# Define mandatory parameters for the subscription ID, resource group, and capacity.
3737
Param (
3838
[Parameter(Mandatory = $true)]
39-
[guid]$subscriptionID,
39+
[guid]$SubscriptionID,
4040
[Parameter(Mandatory = $true)]
41-
[string]$resourcegroup,
41+
[string]$ResourceGroup,
4242
[Parameter(Mandatory = $true)]
4343
[string]$capacity
4444
)
4545

4646
Confirm-TokenState
4747

4848
$AzureBaseApiUrl = Get-PSFConfigValue 'FabricTools.AzureApi.BaseUrl'
49+
$headers = Get-PSFConfigValue 'FabricTools.AzureSession.Headers'
4950

5051
# Define the URL for the GET request.
51-
$getCapacityState = "$AzureBaseApiUrl/subscriptions/$subscriptionID/resourceGroups/$resourcegroup/providers/Microsoft.Fabric/capacities/$capacity/?api-version=2022-07-01-preview"
52+
$getCapacityState = "$AzureBaseApiUrl/subscriptions/$SubscriptionID/resourceGroups/$ResourceGroup/providers/Microsoft.Fabric/capacities/$Capacity/?api-version=2022-07-01-preview"
5253

5354
# Make the GET request and return the response.
54-
return Invoke-RestMethod -Method GET -Uri $getCapacityState -Headers $script:AzureSession.HeaderParams -ErrorAction Stop
55+
return Invoke-RestMethod -Method GET -Uri $getCapacityState -Headers $headers -ErrorAction Stop
5556
}

source/Public/Capacity/Resume-FabricCapacity.ps1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ function Resume-FabricCapacity {
1212
.PARAMETER ResourceGroup
1313
The resource group. This is a mandatory parameter. This is a parameter found in Azure, not Fabric.
1414
15-
.PARAMETER capacity
15+
.PARAMETER Capacity
1616
The capacity. This is a mandatory parameter. This is a parameter found in Azure, not Fabric.
1717
1818
.EXAMPLE
1919
This example resumes a capacity given the subscription ID, resource group, and capacity.
2020
2121
```powershell
22-
Resume-FabricCapacity -subscriptionID "your-subscription-id" -ResourceGroup "your-resource-group" -capacityID "your-capacity"
22+
Resume-FabricCapacity -SubscriptionID "your-subscription-id" -ResourceGroup "your-resource-group" -Capacity "your-capacity"
2323
```
2424
2525
.NOTES
@@ -44,12 +44,13 @@ function Resume-FabricCapacity {
4444
Confirm-TokenState
4545

4646
$AzureBaseApiUrl = Get-PSFConfigValue 'FabricTools.AzureApi.BaseUrl'
47+
$headers = Get-PSFConfigValue 'FabricTools.AzureSession.Headers'
4748

4849
# Define the URI for the request.
4950
$resumeCapacity = "$AzureBaseApiUrl/subscriptions/$SubscriptionID/resourceGroups/$ResourceGroup/providers/Microsoft.Fabric/capacities/$Capacity/resume?api-version=2022-07-01-preview"
5051

5152
# Make a GET request to the URI and return the response.
5253
if ($PSCmdlet.ShouldProcess("Resume capacity $Capacity")) {
53-
return Invoke-RestMethod -Method POST -Uri $resumeCapacity -Headers $script:AzureSession.HeaderParams -ErrorAction Stop
54+
return Invoke-RestMethod -Method POST -Uri $resumeCapacity -Headers $headers -ErrorAction Stop
5455
}
5556
}

source/Public/Capacity/Suspend-FabricCapacity.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ Author: Ioana Bouariu
4545
Confirm-TokenState
4646

4747
$AzureBaseApiUrl = Get-PSFConfigValue 'FabricTools.AzureApi.BaseUrl'
48+
$headers = Get-PSFConfigValue 'FabricTools.AzureSession.Headers'
4849

4950
# Define the URI for the request.
5051
$suspendCapacity = "$AzureBaseApiUrl/subscriptions/$SubscriptionID/resourceGroups/$ResourceGroup/providers/Microsoft.Fabric/capacities/$Capacity/suspend?api-version=2023-11-01"
5152

5253
# Make a GET request to the URI and return the response.
5354
if ($PSCmdlet.ShouldProcess("Suspend capacity $capacity")) {
54-
return Invoke-RestMethod -Method POST -Uri $suspendCapacity -Headers $script:AzureSession.HeaderParams -ErrorAction Stop
55+
return Invoke-RestMethod -Method POST -Uri $suspendCapacity -Headers $headers -ErrorAction Stop
5556
}
5657

5758
}

source/Public/Connect-FabricAccount.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function Connect-FabricAccount {
124124
$azContext = Get-AzContext
125125
}
126126

127-
Write-Message "Connected: $($azContext.Account)" -Level Verbose
127+
Write-Message "Connected: $($azContext.Account)" -Level Info
128128

129129
if ($PSCmdlet.ShouldProcess("Setting Fabric authentication token and headers for $($azContext.Account)")) {
130130
$ResourceUrl = Get-PSFConfigValue -FullName 'FabricTools.FabricApi.ResourceUrl'

0 commit comments

Comments
 (0)