-
Notifications
You must be signed in to change notification settings - Fork 257
Enhancement of Misc/Set-BcContainerFeatureKeys.ps1 to be able to Enable Feature key for particular company. #3696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KM-JAD
wants to merge
19
commits into
microsoft:main
Choose a base branch
from
KM-JAD:master
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+245
−14
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
825b4a6
Fix of Set-BcContainerFeatureKeys.ps1
KM-JAD 77420ee
Merge branch 'microsoft:main' into master
KM-JAD 2c69d6f
Update Set-BcContainerFeatureKeys.ps1
KM-JAD e99723c
Merge branch 'microsoft:main' into master
KM-JAD ed52425
Update Set-BcContainerFeatureKeys.ps1
KM-JAD 7e69e57
Merge branch 'main' into master
freddydk 27dea2f
Update Set-BcContainerFeatureKeys.ps1
KM-JAD 3a4cc6a
Suggestion
freddydk 53d9863
Merge branch 'main' into master
freddydk 6ff38c9
Update Set-BcContainerFeatureKeys.ps1
KM-JAD 3ee18d2
Create Restart-BcEnvironment.ps1
KM-JAD d4e1b61
Merge branch 'microsoft:main' into master
KM-JAD 4d449a0
Update BcContainerHelper.psd1
KM-JAD 6ea5b2c
Update BC.SaasHelper.ps1
KM-JAD 0d317d6
Merge branch 'microsoft:main' into master
KM-JAD 04d1607
Create Get-BcEnvironmentSessions.ps1
KM-JAD e84a568
Create Remove-BcEnvironmentSession.ps1
KM-JAD 6f74cb1
Update BC.SaasHelper.ps1
KM-JAD ca68be1
Update BcContainerHelper.psd1
KM-JAD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<# | ||
.Synopsis | ||
Function for retrieving a list of current sessions for given environment from an online Business Central tenant | ||
.Description | ||
Function for retrieving a list of current sessions for given environment from an online Business Central tenant | ||
Wrapper for https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/administration-center-api_session_management#get-active-sessions | ||
.Parameter bcAuthContext | ||
Authorization Context created by New-BcAuthContext. | ||
.Parameter applicationFamily | ||
Application Family in which the environment is located. Default is BusinessCentral. | ||
.Parameter environment | ||
Name of the environment | ||
.Parameter apiVersion | ||
API version. Default is v2.21. | ||
.Example | ||
$authContext = New-BcAuthContext -includeDeviceLogin | ||
Get-BcEnvironmentSessions -bcAuthContext $authContext -environment "MySandbox" | ||
#> | ||
function Get-BcEnvironmentSessions { | ||
Param( | ||
[Parameter(Mandatory = $true)] | ||
[Hashtable] $bcAuthContext, | ||
[string] $applicationFamily = "BusinessCentral", | ||
[Parameter(Mandatory = $true)] | ||
[string] $environment = "", | ||
[string] $apiversion = "v2.21" | ||
) | ||
|
||
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() | ||
try { | ||
$bcAuthContext, $headers, $endPointURL = Create-SaasUrl -bcAuthContext $bcAuthContext -endPoint "sessions" -environment $environment -applicationFamily $applicationFamily -apiVersion $apiVersion | ||
try { | ||
$Result = (Invoke-RestMethod -Method Get -UseBasicParsing -Uri $endPointURL -Headers $headers) | ||
if ($Result.PSObject.Properties.Name -eq 'Value') { | ||
$Result.Value | ||
} | ||
else { | ||
$Result | ||
} | ||
} | ||
catch { | ||
Write-Host $_ | ||
throw (GetExtendedErrorMessage $_) | ||
} | ||
} | ||
catch { | ||
TrackException -telemetryScope $telemetryScope -errorRecord $_ | ||
throw | ||
} | ||
finally { | ||
TrackTrace -telemetryScope $telemetryScope | ||
} | ||
} | ||
|
||
Export-ModuleMember -Function Get-BcEnvironmentSessions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<# | ||
.Synopsis | ||
Function for stopping and deletion of session from environment (from an online Business Central tenant) | ||
.Description | ||
Function for stop and deletion of session from environment (from an online Business Central tenant) | ||
Wrapper for https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/administration-center-api_session_management#stop-and-delete-a-session | ||
.Parameter SessionID | ||
Session ID of session to be stopped and deleted. | ||
.Parameter bcAuthContext | ||
Authorization Context created by New-BcAuthContext. | ||
.Parameter applicationFamily | ||
Application Family in which the environment is located. Default is BusinessCentral. | ||
.Parameter environment | ||
Name of the environment | ||
.Parameter apiVersion | ||
API version. Default is v2.21. | ||
.Example | ||
$authContext = New-BcAuthContext -includeDeviceLogin | ||
Remove-BcEnvironmentSession -bcAuthContext $authContext -environment "MySandbox" | ||
#> | ||
function Remove-BcEnvironmentSession { | ||
Param( | ||
[Parameter(Mandatory = $true)] | ||
[Hashtable] $bcAuthContext, | ||
[Parameter(Mandatory = $true)] | ||
[string] $sessionID, | ||
[string] $applicationFamily = "BusinessCentral", | ||
[Parameter(Mandatory = $true)] | ||
[string] $environment = "", | ||
[string] $apiversion = "v2.21" | ||
) | ||
|
||
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() | ||
try { | ||
$bcAuthContext, $headers, $endPointURL = Create-SaasUrl -bcAuthContext $bcAuthContext -endPoint "sessions/$sessionID" -environment $environment -applicationFamily $applicationFamily -apiVersion $apiVersion | ||
|
||
Write-Host "Submitting session deletion request for session ID $sessionID in $environment" | ||
|
||
try { | ||
$Result = (Invoke-RestMethod -Method Delete -UseBasicParsing -Uri $endPointURL -Headers $headers) | ||
|
||
} | ||
catch { | ||
Write-Host $_ | ||
throw (GetExtendedErrorMessage $_) | ||
} | ||
Write-Host "Session deletion request submitted" | ||
|
||
} | ||
|
||
|
||
catch { | ||
TrackException -telemetryScope $telemetryScope -errorRecord $_ | ||
throw | ||
} | ||
finally { | ||
TrackTrace -telemetryScope $telemetryScope | ||
} | ||
} | ||
|
||
Export-ModuleMember -Function Remove-BcEnvironmentSession |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<# | ||
.Synopsis | ||
Function for restarting a Business Central online environment | ||
.Description | ||
Function for restarting a Business Central online environment | ||
.Parameter bcAuthContext | ||
Authorization Context created by New-BcAuthContext. | ||
.Parameter applicationFamily | ||
Application Family in which the environment is located. Default is BusinessCentral. | ||
.Parameter environment | ||
Name of the environment for restarting | ||
.Parameter apiVersion | ||
API version. Default is v2.21. | ||
.Parameter doNotWait | ||
Include this switch if you don't want to wait for completion of the environment | ||
.Example | ||
$authContext = New-BcAuthContext -includeDeviceLogin | ||
Restart-BcEnvironment -bcAuthContext $authContext -environment 'MySandbox' | ||
#> | ||
function Restart-BcEnvironment { | ||
Param( | ||
[Parameter(Mandatory = $true)] | ||
[Hashtable] $bcAuthContext, | ||
[Parameter(Mandatory = $true)] | ||
[string] $environment, | ||
[Parameter(Mandatory = $false)] | ||
[string] $applicationFamily = "BusinessCentral", | ||
[Parameter(Mandatory = $false)] | ||
[string] $apiversion = "v2.21", | ||
[Parameter(Mandatory = $false)] | ||
[switch] $doNotWait | ||
) | ||
|
||
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() | ||
try { | ||
$bcAuthContext = Renew-BcAuthContext -bcAuthContext $bcAuthContext | ||
Wait-BcEnvironmentsReady -environments @($environment) -bcAuthContext $bcAuthContext -apiVersion $apiVersion -applicationFamily $applicationFamily | ||
|
||
$bcEnvironments = Get-BcEnvironments -bcAuthContext $bcAuthContext -applicationFamily $applicationFamily -apiVersion $apiVersion | ||
$bcEnvironment = $bcEnvironments | Where-Object { $_.name -eq $environment } | ||
if (!($bcEnvironment)) { | ||
throw "No environment named $environment exists" | ||
} | ||
|
||
|
||
$bcAuthContext, $headers, $endPointURL = Create-SaasUrl -bcAuthContext $bcAuthContext -endPoint "restart" -environment $environment -applicationFamily $applicationFamily -apiVersion $apiVersion | ||
|
||
Write-Host "Submitting environment restart request for $environment" | ||
|
||
try { | ||
$environmentResult = (Invoke-RestMethod -Method POST -Uri $endPointURL -Headers $headers -ContentType 'application/json') | ||
} | ||
catch { | ||
throw (GetExtendedErrorMessage $_) | ||
} | ||
Write-Host "Restart environment request submitted" | ||
|
||
if (!$doNotWait) { | ||
Write-Host -NoNewline "Restarting." | ||
do { | ||
Start-Sleep -Seconds 2 | ||
Write-Host -NoNewline "." | ||
$bcAuthContext = Renew-BcAuthContext -bcAuthContext $bcAuthContext | ||
$Operation = (Get-BcOperations -bcAuthContext $bcAuthContext -apiVersion $apiVersion -applicationFamily $applicationFamily | Where-Object { ($_.productFamily -eq $applicationFamily) -and ($_.type -eq $environmentResult.type) -and ($_.id -eq $environmentResult.id) }) | ||
} while ($Operation.status -in "queued", "scheduled", "running") | ||
Write-Host $Operation.status | ||
if ($Operation.status -eq "failed") { | ||
throw "Could not restart environment with error: $($Operation.errorMessage)" | ||
} | ||
} | ||
} | ||
catch { | ||
TrackException -telemetryScope $telemetryScope -errorRecord $_ | ||
throw | ||
} | ||
finally { | ||
TrackTrace -telemetryScope $telemetryScope | ||
} | ||
} | ||
|
||
Export-ModuleMember -Function Restart-BcEnvironment |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the whole thing, but this missing change currently breaks a pipeline when trying to set/add feature keys, because of the database name.