sexta-feira, março 07, 2025

Oracle OCI Console Connection

These are the steps to access your Windows instance using VNC. I am assuming that you have the necessary permissions and that the network allows traffic on port 443. The details can be found in the Oracle documentation.

Create a local connection:


Copy VNC connection:





This is an example:
Start-Job { Echo N | plink.exe -i C:\SSHKeys\ssh-privatekey.ppk -N -ssh -P 443 -l ocid1.instanceconsoleconnection.oc1.us-chicago-1.anxxeljras4jybackio75le7wjglf6fxxxxx -L 5905:ocid1.instance.oc1.us-chicago-1.anxxeljras4xxxxx:5905 instance-console.us-chicago-1.oci.oraclecloud.com }; sleep 5; plink.exe -i C:\SSHKeys\ssh-privatekey.ppk -N -L 5900:localhost:5900 -P 5905 localhost -l ocid1.instance.oc1.us-chicago-1.axxxxxxxxxxxxxxxa

Your private key must be in PPK format. You can use PuTTYgen to convert the key.

VNC viewer:


Bonus: It is possible to use SAC (Special Administration Console). It is disabled by default, but you can enable it using bcdedit:


bcdedit /ems ON bcdedit /emssettings EMSPORT:1 EMSBAUDRATE:115200


Copy the command and connect. After the connection is established, start a session and connect to it (example below: session 1). You can type "cmd" to create the first session, and it's possible to have multiple sessions.

SAC>ch -si 1:





Done:



domingo, fevereiro 23, 2025

Sitecore CM + Identity behind Azure Front Door

Azure Front Door provides enhanced performance, security, and global load balancing. In this setup, Content Management (CM) and Sitecore Identity (SI) services sit behind Azure Front Door, ensuring secure authentication and optimized traffic routing.

Below the steps to configure a custom domain, with Azure Front Door.

Custom Domain CM: https://cm.maykon.online/
Custom Domain Identity:https://si.maykon.online/

Sitecore Configuration:

CM:

File: Sitecore.Owin.Authentication.IdentityServer.config

Location: /wwwroot/App_Config/Sitecore/Owin.Authentication.IdentityServer/Sitecore.Owin.Authentication.IdentityServer.config

Add this line (Adjust based on your domain):

<setting name="FederatedAuthentication.IdentityServer.CallbackAuthority" value="https://cm.maykon.online" />

Add this (your SI domain, which should be configured in Azure Front Door). In my case, I have a custom domain name: si.maykon.online.

<sc.variable name="identityServerAuthority" value="https://si.maykon.online" />

SI:

File:Sitecore.IdentityServer.Host.xml

Location: /wwwroot/Config/production/Sitecore.IdentityServer.Host.xml

Configure Password recovery:

<PasswordRecoveryUrl>https://cm.maykon.online/sitecore/login?rc=1</PasswordRecoveryUrl>

Add the Cors:

<AllowedCorsOriginsGroup1>https://cm.maykon.online</AllowedCorsOriginsGroup1>

--

File: identityServer.xml

Location: Sitecore.Plugin.IdentityServer/Config/identityServer.xml

Add

<PublicOrigin>https://si.maykon.online</PublicOrigin>

Azure Front Door:

Remove the Origin host header from your origin group ( CM origin ):


In the Web App CM, add the custom domain.


Add the custom domain name at the Web App level; this is required for the Web App to respond to requests.

sábado, janeiro 11, 2025

Azure Function Database Maintenance

I had a maintenance task to run on some Sitecore databases. In the past, I used an automation account, but this time I used a different approach. I created an Azure Function and enabled its identity. Then, I created the database user and configured the script. This script uses the Az and SqlServer modules.

This is how to enable the Identity:




To import the PowerShell module, you can edit the requirements.psd1 file and add the following values:


You need to create the user in the database, this is the script to creation:

CREATE USER [hqew1ww-rg-p04-281306-dbmaintenance] FROM EXTERNAL PROVIDER;

ALTER ROLE db_owner ADD MEMBER [hqew1ww-rg-p04-281306-dbmaintenance];

These is the PowerShell script to run:

param($Timer)
$query = @"
DECLARE @TableName varchar(255) 
DECLARE TableCursor CURSOR FOR
SELECT table_name FROM information_schema.tables WHERE table_type = 'base table'
OPEN TableCursor 
    FETCH NEXT FROM TableCursor INTO @TableName 
    WHILE @@FETCH_STATUS = 0 
    BEGIN
        DBCC DBREINDEX(@TableName,' ',80) 
        FETCH NEXT FROM TableCursor INTO @TableName 
    END
CLOSE TableCursor 
DEALLOCATE TableCursor
"@

# Define the connection parameters
$serverName = "sqlserver.database.windows.net"
$databaseNameCore = "core-db"
$databaseNameMaster = "master-db"
$databaseNameRefData = "refdata-db"
$databaseNameReporting = "reporting-db"
$databaseNameWeb = "web-db"

$token = (Get-AzAccessToken -ResourceUrl https://database.windows.net -AsSecureString).Token
$plainToken = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto(
    [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($token)
)

Invoke-SqlCmd -ServerInstance $serverName -Database $databaseNameCore -AccessToken $plainToken -Query $query

Invoke-SqlCmd -ServerInstance $serverName -Database $databaseNameMaster -AccessToken $plainToken -Query $query

Invoke-SqlCmd -ServerInstance $serverName -Database $databaseNameRefData -AccessToken $plainToken -Query $query

Invoke-SqlCmd -ServerInstance $serverName -Database $databaseNameReporting -AccessToken $plainToken -Query $query

Invoke-SqlCmd -ServerInstance $serverName -Database $databaseNameWeb -AccessToken $plainToken -Query $query