Wiedza
  • 0 Koszyk
  • Kontakt
  • Moje konto
  • Blog
  • MOC On-Demand – co to takiego?
  • MOC On-Demand – Co zyskujesz?
  • Kursy MS

PLESK – NGINX: Cannot assign requested address – during migration not only to Azure

When you trying to move PLESK solution to Azure, but probably not only to Azure and not only PLESK, but also other services based on NGINX you can see this kind of error:

NGINX: Cannot assign requested address.

It is occurred during changing IP address (using plesk bin reconfigurator command described here: https://support.plesk.com/hc/en-us/articles/115001761193-How-to-change-the-IP-address-of-Plesk-server-). To resolve it please add the following line:

net.ipv4.ip_nonlocal_bind = 1

to /etc/sysctl.conf

and run sysctl -p /etc/sysctl.conf.

Sometime especially if you see postfix/smtp Invalid argument error please run:

/usr/local/psa/admin/sbin/mchk –with-spam

It will rebuild postfix malware database and restart postfix.

 

PS: During changing IP address please check /etc/host file also.

CSV <--- import/export ---> Azure NSG

Sometimes we need to import rules to NSG from an Excell file. I had to do it to allow communication with Salesforce – so I had to implement IP whitelist according to this: https://help.salesforce.com/articleView?id=000003652&type=1.

So the script to do it is here:

$importFile = ‘Salesforce-nsg.csv’
$nsgname = ‘acobybylonsg-nsg’
$nsgrg = ‘acobybylonsg’
$subscription=’a3eaae72-4091-4bb6-8e79-ad91f956ac87′
$rulesArray = @()
##############
Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionId $subscription
##############
$nsg = Get-AzureRmNetworkSecurityGroup -Name $nsgname -ResourceGroupName $nsgrg
foreach ($rule in import-csv $importFile)
{
$nsg|Add-AzureRmNetworkSecurityRuleConfig `
-Name $rule.Name `
-Description $rule.Description `
-Protocol $rule.Protocol `
-SourcePortRange ($rule.SourcePortRange -split ‘,’) `
-DestinationPortRange ($rule.DestinationPortRange -split ‘,’) `
-SourceAddressPrefix ($rule.SourceAddressPrefix -split ‘,’) `
-DestinationAddressPrefix ($rule.DestinationAddressPrefix -split ‘,’) `
-Access $rule.Access `
-Priority $rule.Priority `
-Direction $rule.Direction
}
$nsg|Set-AzureRmNetworkSecurityGroup

CSV file is here.

Before doing it could be helpful to export NSG using this script:

$exportPath = ‘C:\temp’
$nsgname = ‘acobybylonsg-nsg’
$nsgrg = ‘acobybylonsg’
$subscription=’a3eaae72-4091-4bb6-8e79-ad91f956ac87′
##############
Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionId $subscription
##############
$nsgs = Get-AzureRmNetworkSecurityGroup -Name $nsgname -ResourceGroupName $nsgrg
#backup nsgs to csv
Foreach ($nsg in $nsgs) {
New-Item -ItemType file -Path “$exportPath\$($nsg.Name).csv” -Force
$nsgRules = $nsg.SecurityRules
foreach ($nsgRule in $nsgRules) {
$nsgRule | Select-Object Name,Description,Priority,@{Name=’SourceAddressPrefix’;Expression={[string]::join(“,”, ($_.SourceAddressPrefix))}},@{Name=’SourcePortRange’;Expression={[string]::join(“,”, ($_.SourcePortRange))}},@{Name=’DestinationAddressPrefix’;Expression={[string]::join(“,”, ($_.DestinationAddressPrefix))}},@{Name=’DestinationPortRange’;Expression={[string]::join(“,”, ($_.DestinationPortRange))}},Protocol,Access,Direction `
| Export-Csv “$exportPath\$($nsg.Name).csv” -NoTypeInformation -Encoding ASCII -Append
}
}

Azure Disk Encryption – upgrade from Azure AD

Old version Azure Disk Encryption with Azure AD app uses Extension AzureDiskEncryption version 1.*.

New Azure Disk Encryption uses Extension AzureDiskEncryption version 2.*. Switching from AAD application Encryption for this encrypted VM isn’t supported yet.

Here is unofficial, not-supported way:

  • On VM using PowerShell as an Admin – disable Encryption, first:

manage-bde -status #write recovery password

Suspend-BitLocker -MountPoint “C:” -RebootCount 0

manage-bde -off c:

manage-bde -status

  • Using regedit delete the following:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Azure\BitlockerExtension

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Azure\HandlerState\Microsoft.Azure.Security.AzureDiskEncryption_1.1.0.4

  • Delete directory:

C:\Packages\Plugins\Microsoft.Azure.Security.AzureDiskEncryption\

  • After that you must shut down VM, not reboot (!) just because Azure Agent install Extension just again. After switching off you have to follow this:

https://rzetelnekursy.pl/azure-disk-encryption-troubleshooting/

Audit what Operating System is trying to run

Sometimes we need to know what application is doing in our operating system. Some scenario when we need it:

  1. We run installer to install application and track what installer trying to launch. I used it to find all components during containerization third party application.
  2. I would like to know what exactly is doing during enabling Azure Disk Encryption.

How to do it?

  • Download – https://download.sysinternals.com/files/Sysmon.zip
  • Unzip it
  • Install using:

sysmon.exe -accepteula –i –h md5,sha256 –n

Sysmon register all network connection and processes that launch in Applications and Services Logs/Microsoft/Widows/Sysmon

  • Alternatively we can do it without installing any application – just run gpedit.msc and configure Audit Process Creation:

  • But it is not all add Include command line in process creation events

After that issue gpupdate /force

Process Creation Events will go to the Security log.

  • Clear in Event Viewer Security log and Sysmon log – you can also delete all logs issuing:

wevtutil el | Foreach-Object {wevtutil cl “$_”}

  • Install application that you can minotor
  • Export Security and Sysmon log to csv
  • Using Notepad++ search for “Process Command Line”. It returns all commands that was issued by the installator.

You can also view 5 last events in every log issuing:

Get-WinEvent -ListLog * -EA silentlycontinue | where-object { $_.recordcount -AND $_.lastwritetime -gt [datetime]::today} | foreach-object { get-winevent -LogName $_.logname -MaxEvents 5 } | Format-Table TimeCreated, ID, ProviderName, Message -AutoSize –Wrap

Consider using and in Azure VM blade.

Other software that can be helpful:

Folder Changes View: https://www.nirsoft.net/utils/folder_changes_view.html

Registry Changes View: https://www.nirsoft.net/utils/registry_changes_view.html

Azure Disk Encryption – Troubleshooting

Azure Disk Encryption technology basis on Windows BitLocker technology– of course only for Windows VMs. Key for BitLocker is stored in Key Vault. Encryption Agent is responsible for transfer key from Key Vault to VM. We have two version old one that use Azure Active Directory (https://docs.microsoft.com/pl-pl/azure/security/azure-security-disk-encryption-prerequisites-aad) and new one without this (https://docs.microsoft.com/pl-pl/azure/security/azure-security-disk-encryption-windows).

AAD version – AzureDiskEncryption version 1.*, without AAD extension 2.*

When to use this manual:

  1. When we use Azure Disc Encryption, before we move VM form one subscription to another we need to suspend BitLocker. Even if we do it and we would like to enable encryption again we need to do it use this procedure
  2. When we enable Azure Disk Encryption (old AAD version) and we receive something like this:

    Provisioning state Provisioning failed. The Key Vault https:… is located in location EastUS2, which is different from the location of the VM, eastus.. KeyVaultAndVMInDifferentRegions

  3. During updating Azure Disk Encryption AAD version to Key Vault only (AzureDiskEncryption 1.* to 2.*) – unsupported
  4. In some scenario after restoring from backup.
  5. To disable Azure Encryption Disk functionality.
  6. AzureDiskEncryption Extension – Provisioning failed
  7. If we see this error:

What we need to do after checking logs C:\WindowsAzure\Logs\Plugins\Microsoft.Azure.Security.AzureDiskEncryption with no-idea what to do next:

  • Suspend Encryption on VM:

Suspend-BitLocker -MountPoint “C:” -RebootCount 0

You can check status issuing:

manage-bde -status

Save numerical recovery password – it can be helpful in any case of problems.

  • Try to disable Encryption on Azure:

$VMName = ‘szyfraadregion’
$VMRGName = ‘szyfr_aad_region’
Disable-AzVMDiskEncryption -ResourceGroupName $VMRGName -VMName $VMName

and

Remove-AzVMDiskEncryptionExtension -ResourceGroupName $VMRGName -VMName $VMName

  • Try to disable encryption on disks OS and data disks:

$RG=$VMRGName
(get-azurermvm -ResourceGroupName $VMRGName -Name $vmname).StorageProfile.OsDisk
$diskName=((get-azurermvm -ResourceGroupName $RG -Name $vmname).StorageProfile.OsDisk.Name)
$disk = Get-AzureRmDisk -ResourceGroupName $RG -DiskName $diskName
$disk.EncryptionSettings.Enabled = $false
$disk.EncryptionSettings.DiskEncryptionKey = $null
$disk.EncryptionSettings.KeyEncryptionKey = $null
$disk | Update-AzureRmDisk
(get-azurermvm -ResourceGroupName $VMRGName -Name $vmname).StorageProfile.DataDisks #Proceed for every disk
$diskName=((get-azurermvm -ResourceGroupName $RG -Name $vmname).StorageProfile.DataDisks.Name)
$disk = Get-AzureRmDisk -ResourceGroupName $RG -DiskName $diskName
$disk.EncryptionSettings.Enabled = $false
$disk.EncryptionSettings.DiskEncryptionKey = $null
$disk.EncryptionSettings.KeyEncryptionKey = $null
$disk | Update-AzureRmDisk


  • Now we need to recreate VM (we cannot usually disable encryption if there is any error) – just Export template – it usually not exports Disk Encryption

  • Delete Only VM – disk networks and rest resources will not be deleted (ensure that VM is deleted – wait a while):

  • Recreate VM (Template Deployment – Build your own template in the editor) – in template paste content from point 4 and remove some thins (if we restore from backup probably we will have less things to remove):

  • Remove OsProfile
  • Remove Image Preference
  • Remove Disk Size
  • Change FromImage to Attach
  • Remove Encryption

Remove marked items.

  • Create VM from template – use the same Resource Grout that we deleted VM.
  • Log to the VM and Disable Encryption:

Now we have disabled Azure Encryption Disk functionality.

You can enable encryption again -please remember that you should use the same version that was use before (AAD or without AAD). Please also remember that in AAD encryption Key vault has to be in the same region as VM.

Azure Disk Encryption with AAD:

$aadClientSecret = “EnableAADEncryptionPa#!@Komplicated”
$aadClientSecretSec = ConvertTo-SecureString -String $aadClientSecret -AsPlainText -Force
$azureAdApplication = New-AzADApplication -DisplayName “DiskEncryptAAD8” -HomePage “https://DiskEncryptAAD8” -IdentifierUris “https://DiskEncryptAAD8” -Password $aadClientSecretSec
$servicePrincipal = New-AzADServicePrincipal –ApplicationId $azureAdApplication.ApplicationId
$keyVaultName = ‘keycentral’
$aadClientID = $azureAdApplication.ApplicationId
$KVRGname = ‘keycentral’
Set-AzKeyVaultAccessPolicy -VaultName $keyVaultName -ServicePrincipalName $aadClientID -PermissionsToKeys ‘WrapKey’ -PermissionsToSecrets ‘Set’ -ResourceGroupName $KVRGname
Set-AzKeyVaultAccessPolicy -VaultName $keyVaultName -ResourceGroupName $KVRGname -EnabledForDiskEncryption
$KeyVault = Get-AzKeyVault -VaultName $KeyVaultName -ResourceGroupName $KVRGname
$DiskEncryptionKeyVaultUrl = $KeyVault.VaultUri
$KeyVaultResourceId = $KeyVault.ResourceId
$sequenceVersion = [Guid]::NewGuid();
Set-AzVMDiskEncryptionExtension -ResourceGroupName $VMRGname -VMName $vmName -AadClientID $aadClientID -AadClientSecret $aadClientSecret -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $KeyVaultResourceId -VolumeType ‘all’ –SequenceVersion $sequenceVersion;

There will be VM restart.

Without AAD:

 

$KVRGname = ‘Key_Vault_Name’;
$VMRGName = $RG                      #Key_Vault_resourceGroup
$KeyVaultName = ‘key_vault;
$KeyVault = Get-AzKeyVault -VaultName $KeyVaultName -ResourceGroupName $KVRGname
$diskEncryptionKeyVaultUrl = $KeyVault.VaultUri;
$KeyVaultResourceId = $KeyVault.ResourceId;
Set-AzVMDiskEncryptionExtension -ResourceGroupName $VMRGname -VMName
$vmName -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $KeyVaultResourceId;

There will be VM restart.

If we change from AAD version 1.0 to version without 2.0 just before last point on the VM we need to uninstall Agent and clean configuration – This is not supported scenario, but you can read about this here.

Please always remember that we can check BitLocker status using:

manage-bde -status

or we can also check Event Viewer:


Azure Application Gateway – Multisite

Usługa Microsoft Azure Application Gateway oferuje rozwiązanie do równoważenia obciążenia protokołu HTTP, które działa w oparciu o równoważenie obciążenia warstwy 7. Może być wzbogacone o usługę Web Application Firewall, które zabezpieczy witrynę przed atakami takimi jak XSS lub SQL injection.

Usługa jest wyjątkowo opłacalna, gdy porównamy cenę tejże usługi w chmurze z usługami On-Prem, gdzie musimy kupić odpowiedni sprzęt to ceny zaczynają się od 5000 i to dolarów. A tak naprawdę powinniśmy kupić droższe urządzenia i dla zapewnienia HA minimum dwa – w Azure cena przetworzenia 1 TB danych z usługą WAF zamknie się w okolicach 200 dolarów miesięcznie – z czego połowa tejże ceny to opłata za przetwarzanie danych.

Poniżej przedstawię konfigurację Azure Application Gateway, w konfiguracji obsługującej dwie witryny. Założono, że serwer aplikacji IIS mamy już uruchomiony (nota bene na maszynie wirtualnej) i serwuje dwie witryny. Jedną pod adresem głównym – czyli http://10.1.0.4/, a drugą pod /Site2 czyli http://10.1.0.4/Site2/. Nasza docelowa konfiguracja będzie wyglądała jak poniżej:

Przy okazji, jeżeli chcemy coś testować za pomocą SSL i https polecam skorzystać z mojego projektu SSL for Every IP – http://ssl4ip.westeurope.cloudapp.azure.com/ gdzie:

10-0-0-1.h.com.pl resolves to 10.0.0.1

11-1-0-1.h.com.pl resolves to 11.1.0.1

192-168-1-1.h.com.pl resolves to 192.168.1.1

8-8-8-8.h.com.pl resolves to 8.8.8.8

Mamy też dostępny certyfikat z kluczem prywatnym dla *.h.com.pl – a więc możemy mieć dostępne witryny, ala https://192-168-1-1.h.com.pl z zaufanym certyfikatem.

Po kolei w portal Azure wykonujemy:

  1. Tworzymy Application Gateway (Sieć musi mieć dedykowaną podsieć dla obsługi Application Gateway)
  2. Dodaj serwery do pul zaplecza
  3. Tworzymy Listener dla portu 443 – tutaj musimy wgrać certyfikat.

  4. Tworzymy Rules dla protokołu SSL 443

Od tego momentu możemy otwierać strone główną używając adresu IP zarówno wykorzystując http, jak i SSL (https). Możemy dodać odpowiednie wpisy w DNS, aby to robić za pomocą nazw FQDN.

Teraz dokonany konfiguracji obsługujących wiele stron, a płacić będziemy tylko za jednego Application Gateway wraz z jednym wystąpieniem WAF.

  1. Kasujemy utworzony Listener na porcie 443 – gdyż, pierwszy w kolejności musi być obsługujący stronę przez podanego FQDN
  2. Tworzymy Listener dla dedykowanego adresu FQDN:

  3. Gdy potrzeba dodajemy odpowiedni wpis w DNS (CNAME) wskazujący na IP – chyba, że korzystamy z projektu Magic DNS – jak w przykładzie.
  4. Dodajemy Listener dla portu 443 ponownie jak w punkcie 3.
  5. Dodajem HTTP settings, jako przekierowanie na inna witrynę – tutaj można by też używać opcji Override host name:

  6. Następnie dodajemy Basic Rule jak tutaj:

  1. Końcowa praca to dodanie usuniętej wcześniej Rule dla portu 443, czyli:


Azure Application Gateway Service provides an HTTP load balancing solution that is based on layer 7 load balancing. It can include Web Application Firewall, which will secure the site against attacks such XSS or SQL injection.

The Azure service is rather cheap If we compare the price with On-Prem services where we need to buy the right equipment then prices start from 5000 USD. And in fact we should buy more expensive devices to provide HA (two devices) – in Azure the price of processing 1 TB of data with WAF service will close around 200 dollars a month – of which half of the price is a data processing fee.

Below I will introduce the configuration of Azure Application Gateway, in a configuration that supports two sites. Assume that there is a IIS application server with two sites. One at the main address that is http://10.1.0.4/, and the other under /site2 – http://10.1.0.4/Site2/. Our target configuration/solution will look like the following:

By the way, if we want to test something using SSL and HTTPS I recommend to use my project SSL for Every IP- http://ssl4ip.westeurope.cloudapp.azure.com/ Where:

10-0-0-1.h.com.pl resolves to 10.0.0.1

11-1-0-1.h.com.pl resolves to 11.1.0.1

192-168-1-1.h.com.pl resolves to 192.168.1.1

8-8-8-8.h.com.pl resolves to 8.8.8.8

You can also download a certificate with private key for *. h.com.pl – so we can have sites, like https://192-168-1-1.h.com.pl with trusted certificate.

How to configure Application gateway that support multisite:

  1. Create Azure Application Gateway (network must have a dedicated subnet for Application gateway support)
  2. Add servers to backend pools
  3. Create a Listener for port 443 – here we have to upload the certificate:

  4. Create Rules for SSL (443 port):

From this point on, we can open the homepage using an IP address both using HTTP and SSL (HTTPS). We can add the appropriate entries in DNS to do so by using FQDN names.

Let’s do a setup that supports multiple pages, and you will only pay for one Application Gateway along with one WAF instance.

  1. Please delete the created Listener on port 443 – because, first in order must be hosting the page by the given FQDN.
  2. Create a Listener for a dedicated FQDN:

  3. We need to add an appropriate DNS (CNAME) entry pointing to the IP-unless we use the Magic DNS project – as in the example.
  4. Add the Listener for port 443 again as in step 3.
  5. Add HTTP settings as a redirect to another site – you can also use the Override host name option here:

  6. Then we add the Basic Rule as here:

  1. The final work is to add the previously removed Rule for port 443, which is:


Completle solution / Pełne rozwiązanie na screenach:

When you cannot do something in portal.azure.com eg. This value neither an IP address nor a fully qualified domain name (FQDN). / Kiedy portal.azure.com nie działa

During configuration of Azure Application Network Gateway – multi-site listener, after entering Host Name you can see:

This value neither an IP address nor a fully qualified domain name (FQDN), event that FQDN is correct.

The solution is to provide different address like rzetelnekursy.pl save it and go to https://resources.azure.com/ – you can see here your complete Azure environment in json format.

After that please go to your resource via subscription – resourceGroups – your resource name – providers – your resource name like here:

Please click Edit, and replace value that value that you enter eg. rzetelnekursy.pl with desired one, like here:

After that press Read/Write and PUT option.

Desired configuration should be saved and you should be able to see it in portal:

The above method can be used not only for configuration, as in this case, but always when portal.azure.com does not allow us to perform some action.


Podczas konfigurowania Azure Application Network Gateway – multi-site listener, po wprowadzeniu nazwy hosta można zobaczyć:

Ta wartość nie adres IP ani w pełni kwalifikowaną nazwę domeny (FQDN), nawet – kiedy FQDN jest poprawna.

Rozwiązaniem jest zapisanie na chwile adres jak rzetelnekursy.pl, a następnie przejście do https://resources.azure.com/ – można zobaczyć tutaj swoje kompletne środowisko Azure w formacie JSON.

Następnie należy przejść do zasobu za pośrednictwem subskrypcji – grypy Zasobów – konkretnego zasobu, jak tutaj:

Proszę kliknąć Edytuj i zastąpić wartość wprowadzaną np. rzetelnekursy.pl pożądaną wartością, jak tutaj:

Następnie pozostaje nam wciśniecie opcji Read/Write i PUT.

Pożądana konfiguracja powinna być zapisana i powinniśmy zobaczyć ją w portalu:

Powyższa metoda może być stosowana nie tylko do konfiguracji, tak jak w tym wypadku Application Gateway, ale zawsze, kiedy portal.azure.com nie pozwala nam wykonać jakiejś akcji.

WinSxs – tutaj trzymane są wszelkie aktualizacje – jak go przeczyścić / How to clean WinSXS directory

Jeżeli jeszcze mamy jakieś stare serwery Windows 2008 lub Windows 2008 R2 (ale nie tylko) może się zdarzyć, iż zacznie na nich brakować miejsca. Związane jest to z tym, iż aktualizacje i ewentualnie stare Service Packi wymagają wyczyszczenia. Aby to zrobić bezpiecznie należy uruchomić program cleanmgr.exe. I powinno się nam pojawić coś takiego:

I dalej mamy graficzny interface użytkownika, więc wiadomo co robić. Na serwerach, aby mieć dostęp do programu teoretycznie należy zainstalować Desktop Expirience i zrestartować serwer. Teoretycznie, a to dlatego, że wystarczy wykonać:

Windows Server 2008 R2 64-bit:

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe %systemroot%\System32

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui %systemroot%\System32\en-us

cleanmgr.exe

Windows Server 2008 64-bit:

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.0.6001.18000_en-us_b9f50b71510436f2\cleanmgr.exe.mui %systemroot%\System3

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.0.6001.18000_none_c962d1e515e94269\cleanmgr.exe.mui %systemroot%\System3\en-us

cleanmgr.exe


If we still have some old Windows 2008 servers or Windows 2008 R2 (but not only), it may happen that there will be a lack of space. This is due to the fact that updates and old Service Packs require cleaning. To do this safely, run the cleanmgr.exe program. And we should see something like this:

And then we have a graphical user interface, so you know what to do. On servers, to access the program theoretically, you must install Desktop Expirience and restart the server. Theoretically, and that’s because you just can to do:

Windows Server 2008 R2 64-bit:

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe %systemroot%\System32

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui %systemroot%\System32\en-us

cleanmgr.exe

Windows Server 2008 64-bit:

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.0.6001.18000_en-us_b9f50b71510436f2\cleanmgr.exe.mui %systemroot%\System3

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.0.6001.18000_none_c962d1e515e94269\cleanmgr.exe.mui %systemroot%\System3\en-us

cleanmgr.exe

H323 Video Terminals and Skype for Business

Skype for Business is still a standard with B2B audio/video communication, but sometime we need to integrate it with our Polycom, Sony and other H323 Video Terminals. Using Test StarLeaf system we can do it without any integration with Skype just forward received invitation to skype@starleaf.com and we receive address that we should connect to our meeting from H323 Video Terminal. Of course our Video Terminal should have internet access and our Skype For Business should accept connection from other tenants. We can test it for free, but if we need to use it on production need to buy a proper service.

At this moment screensharing is not working and we are waiting for Microsoft Teams Support.


Skype for Business nadal jest standardem komunikacji B2B audio / wideo, ale czasami musimy go zintegrować z Terminalami Video H323, takimi jak Polycom czy też Sony. Korzystając z testowego systemu StarLeaf możemy to zrobić bez jakiejkolwiek integracji ze Skype, wystarczy przesłać dalej zaproszenie Skype na adres skype@starleaf.com, a otrzymamy adres, pod który powinniśmy podłączyć się z Terminala Video H323. Oczywiście nasz terminal powinien mieć dostęp do internetu, a nasz Skype For Business powinien akceptować połączenia od innych firm. Całość możemy przetestować zupełnie za darmo, baz żadnych zapisów itp/itd.

W tej chwili przeglądanie ekranu nie działa i czekamy na wsparcie dla Microsoft Teams.


More info/Więcej informacji: https://docs.microsoft.com/en-us/microsoftteams/cloud-video-interop and https://docs.microsoft.com/en-us/skypeforbusiness/plan-your-deployment/video-interop-server

Hybrid Configuration Office 365, Google G-Suite, Exchange OnPrem

Hybrid Configuration Office 365, Google G-Suite, Exchange OnPrem

 

Mail flow Idea:

 

Gmail configuration:

 

 

Exchange On Prem Configuration:

 

There could be also (especially with not all emails synced):

  1. Outgoing Connector to Office 365 with scope @onmicrosoft.com
  2. Outgoing Connector to Google G-Suite with scope @domain.pl

 

Office 365 Connectors Configuration:

 

 

 

Errror mkdir /host_mnt/c: file exists

W przypadku wystąpienia błędu przy startowaniu kontenerów za pomocą docker start lub docker-compose up / docker-compose start zwłaszcza w przypadku Windows należy zrestartować serwis docker’a lub jeszcze lepiej zrestartować cały komputer.


If you receive error like this:

Errror mkdir /host_mnt/c: file exists

Please restart docker service or just restart computer.

Polityka haseł jaka powinna być / Password Policy – na podstawie / based on Azure Identity Secure Score

W czasie Ignite 2018 Microsoft wprowadził Identity Secure Score dostępną w panelu Azure Active Directory. Oprogramowanie informuje nas ile punktów od 1 do 248 zebraliśmy, za prawidłową i bezpieczną konfigurację usług dostępnych w chmurze Microsoft. Dodatkowo widzimy, ile i za co dodatkowych punktów możemy zdobyć. Wszyscy lubimy się porównywać, dlatego też mamy informacje, czy nasz wynik jest powyżej średniej, czy poniżej w sektorze gospodarki.

Poniżej screen wraz z kilkoma wskazówkami dotyczącymi ulepszeń. Po kliknięciu w każde z nich dostajemy dokładną informację co powinniśmy wykonać.

Często dyskutujemy, jak często powinniśmy zmieniać hasła, oraz czy wymuszać je polityką – tutaj wyjaśnienia Microsoft:

Do not expire passwords – Research has found that when periodic password resets are enforced, passwords become less secure. Users tend to pick a weaker password and vary it slightly for each reset. If a user creates a strong password (long, complex and without any pragmatic words present) it should remain just as strong in 60 days as it is today. It is Microsoft’s official security position to not expire passwords periodically without a specific reason. Your current policy is set to require a password reset every 999 days.

What am I about to change? – Under Security & privacy, edit the Password Policy to never let passwords expire. You must be a global admin to edit the password policy.

How will it affect my users? – Your users will no longer need to periodically create new passwords.

Oczywiście wśród zaleceń mamy również zlecenia do włączenia MFA.

Następna polityka to:

Delete/block accounts not used in last 30 days – Deleting or blocking accounts that haven’t been used in the last 30 days, after checking with owners, helps prevent unauthorized use of inactive accounts. These accounts can be targets for attackers who are looking to find ways to access your data without being noticed.

What am I about to change? – Clicking the button below will take you to GitHub where you can download a Powershell script to look up the users who have not logged in for the last 90 days.

Jako odpowiedź na poniższy wpis tutaj link do źródła – polecam zapoznać się (THX- John Flores).


During Ignite 2018 Microsoft introduced Identity Secure Score available in the Azure Active Directory panel. Functionality informs us how many points from 1 to 248 we collected for the correct and safe configuration of services available in the Microsoft cloud. In addition, we see how much and for what we can get additional points. We all like to compare, that’s why we have information if our result is above or below the average.

Below the screen with some tips for improvements. After clicking on each of them, we get the exact information what should we do.

We often discuss how often we should change passwords and whether to force them through GPO or similar- here Microsoft’s explanations:

Do not expire passwords – Research has found that when periodic password resets are enforced, passwords become less secure. Users tend to pick a weaker password and vary it for each reset. If a user creates a strong password (long, complex and without any pragmatic words present) it should remain just like today. It is Microsoft’s official security position. Your current policy is set to require a reset every 999 days.

What am I about to change? – Under Security & privacy, edit the passwords expire. You must be the global admin to edit the password policy.

How will it affect my users? – Your users will need to periodically create new passwords.

Of course, among the recommendations we also have orders to include MFA.

The next policy is:

Delete/block accounts not used in last 30 days – Deleting or blocking accounts that haven’t been used in the last 30 days, after checking with owners, helps prevent unauthorized use of inactive accounts. These accounts can be targets for attackers who are looking to find ways to access your data without being noticed.

What am I about to change? – Clicking the button below will take you to GitHub where you can download a Powershell script to look up the users who have not logged in for the last 90 days.

Here is a MS sorce document (THX- John Flores).

AWS – Disk / VM Export

Czasami potrzebujemy przenieść maszynę wirtualną znajdującą się w chmurze do innego providera chmury, lub wręcz do on-prem. Chociażby po-to, aby mieć backup. O ile w Microsoft Azure sprawa jest banalnie proste – mamy opcje Disk Export i to nawet z GUI. O tyle w przypadku AWS, musimy skorzystać z CLI, za pomocą komendy:

aws ec2 create-instance-export-task –instance-id i-0fe640735a4f8f09b –target-environment microsoft –export-to-s3-task DiskImageFormat=vhd,ContainerFormat=ova,S3Bucket=psensedata,S3Prefix=prefix

Oczywiście wcześniej musimy utworzyć Storage S3 i nadać uprawnienia (The destination bucket must exist and grant WRITE and READ_ACP permissions to the AWS account vm-import-export@amazon.com).

I tutaj możemy spotkać małą niespodziankę, ponieważ może się zdarzyć, iż otrzymamy komunikat:

An error occurred (NotExportable) when calling the CreateInstanceExportTask operation: Only certain instances can be exported. See VM Export documentation for details.

W przypadku Amazon możemy exportować tylko dyski, które wcześniej były zaimportowane do chmury AWS.

Jak sobie poradzić z problemem?

  1. Utworzyć nowy dysk i podłączyć do maszyny wirtualnej
  2. Wykonać kopie sektor po sektorze w przypadku Windows, za pomocą oprogramowania Disk2VHD (omawiane dokładnie tutaj), natomiast w przypadku Linux za pomocą np. dd.
  3. Odegrać tak stworzony image
  4. Zaimportować wspomniany Image (raw) i wyeksportować do jakiegoś bardziej strawnego formatu.

A jak to wykonać po kolei?

Instalujemy AWS CLI i od razu konfigurujemy wydając komendę:

aws configure

AWS Access Key ID oraz AWS Secret Access Key tworzymy na koncie uzytkownika https://console.aws.amazon.com/iam/home#/users w zakładce Security Credentials.

I następnie, wykonujemy komendy – wyświetlenie istniejących instancji typu compute:

aws ec2 describe-instances

Utworzenie nowego dysku o wielkości 32 GB:

aws ec2 create-volume –-size 32 –-region us-east-2 –-availability-zone us-east-2b –-volume-type gp2

Wyświetlenie dysku:

aws ec2 describe-volumes

Przypisanie dysku do instancji:

aws ec2 attach-volume –-volume-id vol-049ddd01841d8c8e4 –-instance-id i-0fe640735a4f8f09b –-device /dev/sdf

Oczywiście volume-id oraz instance-id jest odpowiednio wcześniej odczytane.

Teraz już logujemy się do maszyny wirtualnej i wykonujemy kontrolny restart, a następnie tworzymy partycje, zakładamy filesystem i montujemy (przykład freebsd – dla linux tylko prościej):

geom disk list

gpart show -l

gpart create -s GPT xbd5

gpart add -t freebsd-ufs xbd5

newfs -U /dev/xbd5p1

mount /dev/xbd5p1 /mnt

I wykonujemy kopie sektor po sektorze:

dd if=/dev/ada0 of=/mnt/disk.img

Aby nieco przyspieszyć możemy dodać bs=100M.

Tak przygotowany image musimy dostosować, do bardziej strawnego formatu, aby się z niego zabootować – i tutaj korzystamy albo z Open Stack, albo z VirtualBox.

Poniżej screenshot z uruchomionej instancji pfSense na lokalnym Oracle VirtualBox, z wcześniej wyeksportowanego w wyżej wymieniony sposób dysku.

Import dysku możliwy jest po wykonaniu komendy:

vboxmanage internalcommands createrawvmdk -filename “disk.vmdk” -rawdisk “disk.raw”

Inna opcja migracji z AWS to użycie Azure Site Recovery (co nie raz było omawiane, ale tylko dla wspieranych systemów operacyjnych i nie freebsd) lub nietestowanego jeszcze przeze mnie rozwiązania w AWS typu https://vmplace.eu/Image/azurezilla—physical-virtual-to-azure-converter.

Sometimes we need to move a virtual machine located in the cloud to another cloud provider, or even to on-prem (e.g. for a backup purpose). In Microsoft Azure it is very simple – we have Disk Export in GUI too. In the case of AWS, we need to use the CLI, using the command:

aws ec2 create-instance-export-task –instance-id i-0fe640735a4f8f09b –target-environment microsoft –export-to-s3-task DiskImageFormat=vhd,ContainerFormat=ova,S3Bucket=psensedata,S3Prefix=prefix

Oczywiście wcześniej musimy utworzyć Storage S3 i nadać uprawnienia (The destination bucket must exist and grant WRITE and READ_ACP permissions to the AWS account vm-import-export@amazon.com).

Here we can meet a small surprise, because it may happen that we receive a message:

An error occurred (NotExportable) when calling the CreateInstanceExportTask operation: Only certain instances can be exported. See VM Export documentation for details.

In the case of Amazon, we can only export disks that were previously imported to the AWS cloud.

How to deal with the problem?

  1. Create a new disk and connect to the virtual machine
  2. Make a sector-by-sector copy (for Windows using Disk2VHD), and for Linux, for example, dd.
  3. Copy a created image
  4. Import the mentioned Image (raw) and export to some more digestible format.

Step by Step:

Install AWS CLI and configure it using:

aws configure

AWS Access Key ID and AWS Secret Access Key can be created on the user’s account page https://console.aws.amazon.com/iam/home#/users at the Security Credentials tab.

Next run command to display compute instances:

aws ec2 describe-instances

Create new 32 GB disk:

aws ec2 create-volume –-size 32 –-region us-east-2 –-availability-zone us-east-2b –-volume-type gp2

Display Disk:

aws ec2 describe-volumes

Assign disk to the instance:

aws ec2 attach-volume –-volume-id vol-049ddd01841d8c8e4 –-instance-id i-0fe640735a4f8f09b –-device /dev/sdf

Of course, volume-id and instance-id should be taken from above commands.

Now we can log in to the virtual machine and perform a control restart, then we create partitions, create filesystem and mount it (example freebsd – for linux it is simpler):

geom disk list

gpart show -l

gpart create -s GPT xbd5

gpart add -t freebsd-ufs xbd5

newfs -U /dev/xbd5p1

mount /dev/xbd5p1 /mnt

And make sector by sector copy:

dd if=/dev/ada0 of=/mnt/disk.img

We can add bs=100M to speed up the process.

This image we can upload to Open Stack or use it with Virtual Box. Disk import can be done after:

vboxmanage internalcommands createrawvmdk -filename “disk.vmdk” -rawdisk “disk.raw”

Another option of migrating from AWS is the use of Azure Site Recovery (which has been discussed more than once, but only for supported operating systems and not freebsd) or use untested solution in AWS like https://vmplace.eu/Image/azurezilla—physical-virtual-to-azure-converter.

Ściąganie plików za pomocą PowrShela, How to download file using PowerShell:

Invoke-WebRequest -Uri $url -OutFile $output #wolne, ale z progress barem / slow but with progressbar

(New-Object System.Net.WebClient).DownloadFile($url, $output) # szybkie, ale bez progras baru / fast, but without progress bar

Start-BitsTransfer -Source $url -Destination $output # szybkie, z progress barem, ale BITS musi być uruchomiony i jak coś jest w kolejce to będziemy czekać. Jest tryb asynchroniczny / Fast with progress bar, but bits should be working

A swoją drogą najszybsze rezultaty pod względem szybkości osiągamy starymi dobrymi Acceleratorami, które były używane za czasów modemów – mój ulubiony: http://www.internetdownloadmanager.com/

Windows 10 i Windows 2019 – Linux LCOW Containers coexist with Windows Containers – Azure App Service Container Support

Konteneryzacja w systemach Windows Server po raz pierwszy była pokazywana na konferencji Microsoft Build w 2016 roku – co ciekawie wtedy do takiego kontenera (windowsowego) można było połączyć się po RDP i wszystkie operacje wykonywać nie za pomocą polecenia docker, a za pomocą PowerShell! Jeszcze w tym samym roku mogliśmy sami dotykać kontenerów w Windows 10, co pokazywałem w ramach relacji z Ignite 2016 – polecam Channel9.

Jak dzisiaj wygląda świat kontenerów w Windows 10 i Windows Server 2019. Zakładam, że mamy w miarę nową wersje systemu Windows (poniższe wykonywane na wersji Windows 10 1809) musimy zainstalować docker’a – najlepiej z oficjalnej strony. Docker instaluje się jako serwis i przy zegarku możemy zobaczyć jego status, gdzie po raz pierwszy zobaczymy informacje (zakładam, iż nie mamy wymienionych komponentów zainstalowanych):

Po wciśnięciu OK zainstalują się komponenty kontenerów oraz Hyper-V. Możemy wydać kilka komend aby uruchomić kontener i tak np.:

docker run -it busybox         #uruchomienie obrazu mini dystrybucji linuxa w trybie interaktywnym

ls

exit

dosker ps -a             #wyświetlenie wszystkich kontenerów także zatrzymanych

docker start id_kontenera     #uruchomienie kontenera

docker ps             #wyświetlenie uruchomionych kontenerów

Jak to możliwe, że linuxa uruchamiamy z pod Windows – a po prostu działa poniższy mechanizm:

Czyli pod spodem działa nam maszyna wirtualna MobyLinux, którą zresztą możemy podejrzeć w Hyper-V:

Jeżeli teraz chcemy uruchomić kontener Windows i wykonamy komendę:

docker run -it -d –name nano microsoft/nanoserver:1709

otrzymamy błąd:

docker: image operating system “windows” cannot be used on this platform.

No właśnie, do tej pory nie mogliśmy jednocześnie uruchamiać kontenerów Windows’owych razem z Linux’owymi, a musieliśmy się między nimi przełączać – prawy przycisk na wielorybie i wybieramy Switch to Windows containers…

Kontenery Windows mogą w systemach serwerowych działać w trybie natywnym lub w trybie Izolacji Hyper-V. W Windows 10 tylko i wyłącznie w trybie izolacji Hyper-V. W tym momencie możemy już uruchomić np. IIS w kontenerze Nano Serwer, poleceniem:

docker run -it -d –name nano microsoft/nanoserver:1709

Od wersji Docker for Windows 17.11 z Windows 10 1809, możemy również w trybie izolacji Hyper-V, uruchamiać kontenery Linuxow’owe wraz z kontenerami Windowsowymi, które to działają jednocześnie. Aby to zrobić należy włączyć tryb eksperymentalny w Docker’ze:

Od tego momentu możemy uruchamiać i kontenery Linux’owe i Windows’owe:

docker run -it -d –name nano2 microsoft/nanoserver:1709

docker run -d –name httpd2 -p 8080:80 httpd

Jak to działa:

Kontenery LCOW, działają w ramach minimalnej dystrybucji linux’a – LinuxKit (ciągle w trybie rozwoju).

Wkrótce przedstawię kilka zastosowań praktycznych kontenerów, obecnie warto zapoznać się z moim artykułem Jak rozpoznać i debugować aplikacje działającą w Windows Container.

Jeżeli chodzi o Microsoft Azure, to kontenery Linux’owe mogą zostać uruchomione na kilka rodzajów, na Ignite 2018 pobawiłem się w trybie nadzorowanym kontenerami Windowsowymi w ramach Web App (obecnie public preview), jak niżej:

Jeżeli chodzi o AWS – to tutaj mamy obecnie troszkę większe możliwości:


The first time that the containerization for the Windows Server systems was shown at the Microsoft Build Conference in 2016 year. What was interesting – it was possible to connect to container via RDP connection and all operations was performed not by a docker command, but using PowerShell! In the same year, we were able to touch the containers in Windows 10, which I showed in the context of the relation from Ignite and we can still watch in at the Channel9.

How today the world of containers looks like in Windows 10 and Windows Server 2019. We need to install a docker (https://www.docker.com/products/docker-desktop). I am using Windows 10 1809 for this screenshots. Docker installs as a service and we can see its status on behind the clock. For the first time we see this screen:

After pressing OK, container components and Hyper-V will be installed. We can issue a few commands to start the container, for an example:

docker run -it busybox         #launching the linux mini distribution image in interactive mode

ls

exit

dosker ps -a                            # displaying all containers (also stopped)

docker start icontainer_id  #start container

docker ps                                 # display of started containers

How is it possible that we run linux under Windows – see this:

So underneath we have a MobyLinux virtual machine, which can be seen in Hyper-V:

If you now want to start Windows container and execute the command:

docker run -it -d –name nano microsoft/nanoserver:1709

we receive:

docker: image operating system “windows” cannot be used on this platform.

Until today we have not been able to run Windows containers together with Linux at the same time, and we had to switch between them – the right button on the whale and choose Switch to Windows containers…

Windows containers can run on server systems in native mode or in Hyper-V isolation mode. On Windows 10, only in Hyper-V isolation mode. Let’s try to run Windows IIS container:

docker run -it -d –name nano microsoft/nanoserver:1709

Since Docker for Windows 17.11 with Windows 10 1809, we can also run Linux containers with Windows containers that work simultaneously in Hyper-V isolation mode. To do this, enable the experimental mode:

From that moment, we can run Linux and Windows containers:

docker run -it -d –name nano2 microsoft/nanoserver:1709

docker run -d –name httpd2 -p 8080:80 httpd

How is it works:

LCOW containers operate as part of the minimal linux distribution – LinuxKit (under development).

I will soon introduce some practical applications of containers, so stay tuned.

In Microsoft Azure Linux containers can be run on several ways, on Ignite 2018 I played in supervised mode with Windows containers as part of the Web App (currently public preview), as below:

According to the AWS – here we have a bit more possibilities:

Literatura / Literature:

https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/linux-containers

https://forums.docker.com/t/linux-container-in-w2k16/26321/3

https://azure.microsoft.com/pl-pl/blog/announcing-the-public-preview-of-windows-container-support-in-azure-app-service/

https://rzetelnekursy.pl/jak-rozpoznac-i-debugowac-aplikacje-dzialajaca-w-windows-container-how-to-recognize-and-debug-applications-running-in-windows-container/

https://github.com/linuxkit/linuxkit

Dostrajanie Failover Cluster dla Hyper-V i nie tylko

W poprzednim artykule ogarnęliśmy ruch między węzłowy, a w szczególności CSV. Tym razem zajmiemy się podkręceniem Clustra, aby działał jak najbardziej niezawodnie.

Błąd typu Operating System failure (Windows bug check, STOP: 0x0000009E (blue screen).

Czasami się zdarza się, że usługa Cluster przez chwile nie odpowiada, a my nie lubimy blue-screenów i aby zapobiec błędom STOP w przypadku braku odpowiedzi usługi Cluster należy wykonać:

(Get-Cluster).HangRecoveryAction=1

Inne parametry to:

0 = Wyłączenie mechanizmu
1 = Logowanie zdarzenia
2 = Zatrzymanie usługi Cluster
3 = Wygenerowanie błędu Stop STOP: 0x0000009E

Idąc dalej podobne ustawienia należy wykonać dla dysków Clustrowych.

Basic check – to tzw. Podstawowy (LooksAlive Health Check) – kiedy zostanie wykonany i zwrócona zostanie wartość True – oznacza, że dysk “powinien działać”

Bardziej Zaawansowany test to Thorough check (IsAlive), wykonywany co określony czas oraz jeżeli test podstawowy zwrócił błąd.

W przypadku bardziej obciążonego systemu warto te czasy wydłużyć, co pozwoli uniknąć błędów zwłaszcza podczas backupu, objawiających się tym iż maszyna wirtualna straciła połączenie do dysku.

LooksAlive: By default, a brief check is performed every 5 seconds to verify that a disk is still available. The LooksAlive check determines whether a resource flag is set. This flag indicates that a device has failed. For example, a flag may indicate that periodic reservation has failed. The frequency of this check is user definable.

IsAlive: A complete check is performed every 60 seconds to verify that the disk and the file system can be accessed. The IsAlive check effectively performs the same functionality as a “dir” command that you type at a command prompt. The actual command it uses is the “FindFirstFile()” API. The frequency of this check is also user definable.

Podobnie jak ustawienia dotyczące dostępnego komponentu, takiego jak dysk mamy też ustawienia dot. poszczególnych zasobów. I tak dla maszyn wirtualnych, aby w przypadku obciążenia za szybko nie były uznawane, za niedziałające proponuje ustawić następujący parametr.

(Get-ClusterResourceType “Virtual Machine”).DeadlockTimeout = 990000

Idąc dalej jeżeli maszyna wirtualna, zwłaszcza przy obciążonym systemie nie startuje I pojawi się błąd:

Cluster resource <Resource> timed out. If the pending timeout is too short for this resource, consider increasing the pending timeout value.

Wówczas warto zwiększyć czas potrzebny na uruchomienie się, zwłaszcza dużej maszyny:

(Get-ClusterResourceType “Virtual Machine”).PendingTimeout=800000
(Get-ClusterResourceType “Virtual Machine Configuration”).PendingTimeout=800000

W celu zwiększenia wydajność podsystemu dyskowego CSV warto włączyć Cache wykonując z PowerShell’a:

(Get-Cluster).BlockCacheSize=1024 #Zwiększenie cache do 1 GB – zalecam zwiększenie do 2GB

Jako, że jedna lub niedoborze, kilka maszyn wirtualnych mogą wysycić nam sieć i związaną z kartą sieciową procesor oraz tym bardziej dysk dlatego sugeruje wprowadzenie ograniczeń, i ograniczyć dla dysku maksymalnie 10000 IOPS:

get-vm|Get-VMHardDiskDrive|Set-VMHardDiskDrive -MaximumIOPS 10000 -MinimumIOPS 8000

Informacja dotycząca minimalnej liczby IOPS – w przypadku osiągniecia tejże wartości odpowiedni wpis zostanie zapisany i będzie można go podejrzeć za pomocą Event Viewer’a.

Ograniczenia dla karty sieciowej maszyny wirtualnej:

Get-VMNetworkAdapter -All|Set-VMNetworkAdapter -MaximumBandwidth 300Mb

Powyższe polecenie skonfiguruje również partycje 0, czyli system operacyjny Hyper Visor’a również będzie podlegał ograniczeniom, co nie jest zalecane – dlatego, proponuje wykonać:

Get-VMNetworkAdapter -ManagementOS |Set-VMNetworkAdapter -MaximumBandwidth 50000Mb

A wszystko w celu, aby maszyny wirtualne nie wysyciły sieci i procesora, bo sieć w rozwiązaniach typu Cluster jest bardzo ważna. To przez nią odbywa się ruch HeartBeat, który jest bardzo ważny i powinien być traktowany priorytetowo. Jeżeli poszczególne nody Clustra stracą kontakt na ponad 20 sekund ze sobą po wszystkich sieciach, dla których zdefiniowany jest HeartBeat wówczas taki nod wypadnie z Clustra i wszystkie zasoby z niego zostaną przeniesione na innego noda. Możemy to stwierdzać analizując log Clastrowy, który możemy pobrać komendą:

Get-ClusterLog -Destination C:\AnalizaLogow -UseLocalTime

A w nim zobaczymy takie wpisy:

Line 13821: 00001cd4.000145bc::2018/06/11-10:40:54.588 INFO [IM] Marking Route from 10.11.105.12:~3343~ to 10.11.105.11:~3343~ as down
Line 13960: 00001cd4.000145bc::2018/06/11-10:40:54.591 INFO [IM] Marking Route from 192.168.11.8:~3343~ to 192.168.11.3:~3343~ as down

W Event Viewerze bądą to wpisy:

Cluster network interface node1 – Heartbeat’ for cluster node node1 on network ‘heartbeat’ failed.
Cluster Shared Volume Volume has entered a paused state because of ‘(c0000203)’. All I/O will temporarily be queued until a path to the volume is reestablished.
Cluster node ‘waw01-hpv36’ was removed from the active failover cluster membership. The Cluster service on this node may have stopped. This could also be due to the node having lost communication with other active nodes in the failover cluster.

Warto wspomnieć, że komunikacja HeartBeat odbywa się z wykorzystaniem protokołu UDP i dlatego warto zwiększyć owy czas, że nod clustra nie widzi innych nodów, np. ze względu na jego przeciążenie. Maksymalnie możemy zwiększyć czas do 120 sekund.

(Get-Cluster).sameSubnetThreshold=120
(Get-Cluster).crossSubnetThreshold=120

Dochodzimy do setna, jak już wspomniałem sieć jest bardzo ważna w komunikacji i wykorzystywana jest przynajmniej w 4 wartstwach (W przypadku wirtualizacji):

  • LiveMigration;
  • Ruch CSV;
  • HeartBeat;
  • Komunikacja maszyn wirtualnych;
  • Komunikacja administracyjna np. Przegrywanie plików, backupów.

Powyższe opisywałem w poprzednim artykule, a teraz zajmiemy się obciążeniem procesor versus Karta Sieciowa i maszyna wirtualna. Aby ruch sieciowy wygenerowany przez maszynę wirtualną rozkładał się na poszczególne procesory – i to nie na procesor “0”, który i tak ” ma co robić” powinniśmy włączyć i skonfigurować VMQ.

Get-NetAdaptervmq # Wyświetlenie informacji

To do czego powinniśmy doprowadzić, to aby każda karta była przypisana do innego procesora (core) i robimy to za pomocą polecenia:

Set-NetAdapterVmq -Name “SLOT 3 Port 2” -BaseProcessorNumber nr_procesora

Jeżeli karty pracują w Team (co jest zalecane) wówczas każda z kart powinna wykorzystać maksymalnie połowe procesorów (przy założeniu, że w teamie są 2 karty sieciowe), w przypadku trzech kart sieciowych wartość 1/3 itd.

-MaxProcessors ilość_procesorów

Powyższe ma zastosowanie tylko wtedy, gdy włączmy VMQ, co jest zalecane dla kart o szybkości powyżej 1GB. Dla kart 1 GB i Broadcom nie jest to zalecane, a bynajmniej należy się upewnić, iż mamy aktualny sterownik. Oczywiście w założeniu mam, że dana karta sieciowa wykorzystywana jest przez maszyny wirtualne.

Robimy to dodając parametr.

-Enabled $True

Przykład komendy:

Set-NetAdapterVmq -Name “SLOT 3 Port 2” -BaseProcessorNumber 3 -MaxProcessors 16 -Enabled $True

W przypadku kiedy mamy używane HT w procesorach BaseVmqProcessor może być tylko parzysty.

Dodatkowo jeżeli w jednym Teamie pracują 2 karty sieciowe Max Processors nie może na siebie nachodzić. Czyli jeżeli pierwsza karta używa procesora 2 i mamy MaxProcessors na 14, wówczas pierwsza karta może używać procesora 2,3,4,5,6,7,8,9,10,12,12,13,14,15. A drugą kartę powinniśmy ustawić, iż używa procesora 16 i max Processors również na 14.

Aby maksymalnie wykorzystać moc karty sieciowej powinniśmy ustawić Receive Buffers na maksymalną wielkość, dla różnych kart będą to wielkości typu 4096, 2048 lub Maximum.

Odczyt aktualnej wielkości:

Get-NetAdapterAdvancedProperty “SLOT 3 Port 2” -DisplayName “Receive Buffers”

Ustawienie:

set-NetAdapterAdvancedProperty “SLOT 3 Port 2” -DisplayName “Receive Buffers” -DisplayValue 4096

lub

set-NetAdapterAdvancedProperty “SLOT 3 Port 2” -DisplayName “Receive Buffers” -DisplayValue “Maximum”

Na zakończenie pamiętajmy, iż we współczesnych systemach domyślnie włączony jest Multichanel dla ruchu SMB, a więc przy kopiowaniu plików użyte zostaną wszystkie kary sieciowe, co z kolei może wysycić ruch na karcie HeartBeat i CSV.

Wyłącznie multichanel:

Set-SMBClientConfiguration –EnableMultichannel $False

Set-SmbServerConfiguration -EnableMultiChannel $false

 

Mariusz Ferdyn

Gdyby były jakieś pytania zapraszam do kontaktu.

PS:

Pomyślcie też czy maszyna wirtualna musi przenosić się na inny nod clustra w przypadku braku sieci:

get-vm|Set-VMNetworkAdapter -NotMonitoredInCluster $True

Sprawdzenie poprawności działania komunikacji CSV dla Microsoft Failover Cluster dla Hyper-V

Rozwiązania wysokiej dostępności z wykorzystaniem technologii Microsoft Failover Cluster dla Hyper-V wraz z Clustered Shared Volume konfiguruje się dosyć prosto i można powiedzieć, że rozwiązanie działa out of the box.

Problemy mogą zacząć się, gdy środowisko się rozrasta i/lub zaczyna być poważnie obciążone np. Podczas backupu Clustered Shared Volumes.

W przypadku Clustered Shared Volumes odczyt i zapis danych odbywa się z wykorzystaniem bezpośredniego połączenia każdego węzła z zasobem dyskowym, czy też po iSCSII lub Fibre Chanell. Wyjątek tutaj stanowi zapisywanie metadanych – czyli np. powiększanie pliku, zmiana uprawnień – wówczas wykorzystywany jest ruch CSV po sieci Ethernet do węzła, który jest właścicielem danego dysku.

W przypadku jakichkolwiek problemów z komunikacją możemy ujrzeć następujące błędy, w końcowym stadium powodujące wyłączenie jednego z węzłów.

Source EventID Details
FailoverClustering

1126

Cluster network interface ‘Heartbeat (NIC1) (1)’ for cluster node on network ‘Heartbeat’ is unreachable by at least one other cluster node attached to the network. The failover cluster was not able to determine the location of the failure. Run the Validate a Configuration wizard to check your network configuration. If the condition persists, check for hardware or software errors related to the network adapter. Also check for failures in any other network components to which the node is connected such as hubs, switches, or bridges.
i40ea

27

Intel(R) Ethernet Converged Network Adapter X710 #2 Network link is disconnected.
Hyper-V-VmSwitch

22

Media disconnected on NIC /DEVICE/ (Friendly Name: Microsoft Network Adapter Multiplexor Driver).
MsLbfoSysEvtProvider

16949

Member Nic Disconnected.
i40ea

27

Intel(R) Ethernet Converged Network Adapter X710 Network link is disconnected.
MsLbfoSysEvtProvider

16949

Member Nic Disconnected.
MsLbfoSysEvtProvider

16945

Member Nic Disconnected.
sdddsm

24

MPDISK reservation preempted.
FailoverClustering

1135

Cluster node was removed from the active failover cluster membership. The Cluster service on this node may have stopped. This could also be due to the node having lost communication with other active nodes in the failover cluster. Run the Validate a Configuration wizard to check your network configuration. If the condition persists, check for hardware or software errors related to the network adapters on this node. Also check for failures in any other network components to which the node is connected such as hubs, switches, or bridges.
FailoverClustering

5120

Cluster Shared Volume ‘Volume3’ has entered a paused state because of ‘(c000020c)’. All I/O will temporarily be queued until a path to the volume is reestablished.
FailoverClustering

5120

Cluster Shared Volume ‘Volume4’ has entered a paused state because of ‘(c000020c)’. All I/O will temporarily be queued until a path to the volume is reestablished.
i40ea

27

Intel(R) Ethernet Converged Network Adapter X710 Network link is disconnected.
Hyper-V-VmSwitch

22

Media disconnected on NIC /DEVICE/ (Friendly Name: Microsoft Network Adapter Multiplexor Driver).
MsLbfoSysEvtProvider

16949

Member Nic Disconnected.
i40ea

27

Intel(R) Ethernet Converged Network Adapter X710 #2 Network link is disconnected.

Najważniejsze to rozdzielenie ruchu sieciowego na różne karty sieciowe dla:

  • Maszyn Wirtualnych
  • Live Migration
  • HeartBeat
  • Ruchu CSV
  • Backupu (o ile wykonywany jest po sieci)

Nawet jeżeli nie mamy tyle fizycznych kart sieciowych do rozdzielenia ruchu zastosujmy wirtualne karty sieciowe (Add-VMNetworkAdapter), dodatkowo rozważmy zastosowanie Teamingu kart sieciowych. Poprawny opis konfiguracji sieci w Microsoft Failover Cluster znajdziemy tutaj: https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/jj735302%28v=ws.11%29.

Po, których kartach sieciowych odbywać się ma ruch Kliencki (Maszyn Wirtualnych), HeartBeat oraz ruch Live Migration ustawiamy w Failover Cluster Manager.

Domyślnie ruch CSV będzie odbywał się po sieci HeartBeat – co zazwyczaj jest dobrym wyborem, chyba, że sieć ta nie jest za szybka. Do kontroli, którą siecią ma odbyć się ruch CSV służą metryki. Aby je wyświetlić używamy komendy:

Get-ClusterNetwork|ft Name,Metric,AutoMetric

Użyta zostaje sieć z najniższą metryką i możemy ją zmodyfikować poniższą komendą, aby wybrać sieć dedykowaną do ruch CSV:

(Get-ClusterNetwork eth0).metric=800

Jeżeli natomiast, z jakiś przyczyn chcemy aby ruch CSV odbywał się po sieci klienckiej powinniśmy wykonać (zazwyczaj nie jest to zalecane):

(get-cluster).UseClientAccessNetworksForSharedVolumes=$true

Dodatkowo aby zoptymalizować ruch między węzłami Clustra warto zaznaczyć opcje Microsoft Failover Cluster Virtual Adapter Performance Filer dla kart sieciowych .

Sieć dotyczącą backupu trzeba skonfigurować w programie do owego backupu i w przypadku Veeam robimy to jak poniżej:

Jeszcze raz chciałbym uczulić na odseparowanie ruchu dla CSV i HeartBeat od innego ruchu, gdyż wysycenie łącza dla CSV i Heartbeat może doprowadzić do awarii Clustra.

Na zakończenie warto też zaimplementować reguły QoS dla Clustra, jak poniżej:

# Live Migration
New-NetQosPolicy “Live Migration” –LiveMigration –Priority 4
# CSV
New-NetQosPolicy “SMB” –SMB –Priority 5
# HeartBeat
New-NetQosPolicy “HeartBeat” -IPDstPort 3343 –Priority 6
# Wlaczenie na wszystkich interface QoS
get-VMNetworkAdapter -ManagementOS|Set-VMNetworkAdapter -IeeePriorityTag On

Aby sprawdzić, czy nie następuje wysycenie łącza oraz komponentów systemu odpowiedzialnych za komunikacje miedzy-nodową oraz docelowo wyrzucenie jakiegoś węzła z Clustra proponuje użyć oprogramowania iperf i wygenerować ruch multicast. Proszę używać programu iperf skompilowanego natywnie dla windows w wersji 2, gdyż tylko on prawidłowo obsługuje muliticast. iperf-2.0.4-win32.

Na jednym Nodzie proponuje uruchomić komendę:

iperf.exe   -c 224.0.166.111 -u -T 100 -i 1 -b 9000000000 -t 3600

na drugim Nodzie natomiast:

iperf -s -u -B 224.0.166.111 -i 1

Z założenia ruch ten nie powinien odbywać się poprzez sieć dla CSV oraz Heartbeat. Testy możemy powtórzyć z maszyn wirtualnych. Proszę zauważyć, iż w powyższym teście, również obciążamy wirtualnego switcha (o ile dojdzie do niego ruch), gdyż to on musi zmultiplikować ruch multicast do każdej maszyny wirtualnej.

Możemy zintensyfikować testy uruchamiając kolejne instancje oprogramowania iperf dla kolejnych adresów multicast np. 224.0.166.112, 224.0.166.113, 224.0.166.114.

Przy okazji wspomnę, iż powyższy test pomaga zlokalizować bug w kartach sieciowych Intel(R) Ethernet Converged Network Adapter X710 (Driver Version 1.8.94.0, Firmware: Version: 18.5.17), które w przypadku zainstalowania roli Hyper-V, oraz uruchomienia VMQ rozłączają się, co automatycznie powoduje awarie rozwiązania wysokiej dostępności.

Azure Stack – Web + Mobile, Web App – Oops! – Could not create Web App

Zaraz po zainstalowaniu App Service, mimo to iż widzimy w panelu zarządzającym, iż All Roles Ready, jak tutaj:

Powinniśmy do Planów dodać Serwis Microsoft.Web App:

Zaraz potem jeżeli będziemy chcieli wdrożyć Web App to ujrzymy:

Co robić – zalogujmy się za pomocą RDP do cn0-vm, być może trzeba będzie prze edytować Network Security Group i uruchommy Web Cloud Management Console – sprawdźmy, czy wszystkie serwery działają prawidłowo – a ich uruchomienie może zająć chwilkę:

Wróćmy do statuu App Service i tym razem ujrzymy, że nie wszystkie role są uruchomione. W zależności od szybkości naszego sprzętu może to trochę potrwać (w moim około 2 godzin a hosta miałem dość silnego).

Na zakończenie zobaczymy jednak sukces:

A swoją drogą Web Cloud Management Console to dość fajne narzędzie za pomocą, którego mamy kontrolę nad infrastrukturą App Service i chociażby za pomocą jednego kliknięcia możemy połączyć się za pomocą RDP do Publishera:

 

I pamiętajmy, iż nie możemy kreować Web Aplikacji z adminportal, a tylko z poziomu Subskrybcji (np: https://portal.local.azurestack.external/).


Right after installing the App Service, even though we see in the management panel that All Roles Ready, like here:

We should add the Microsoft.Web App to the Plans:

Immediately afterwards, if we want to implement the Web App, we will see it:

What to do?- Just using RDP go to cn0-vm, you may have to edit the Network Security Group and run the Web Cloud Management Console – let’s check that all servers are working properly – and that they may take a while to start:

Let’s go back to the App Service and this time we will see that not all roles are running. Depending on the speed of our equipment, this may take some time (I have to wait about 2 hours):

However, at the end – we will see success:

By the way, Web Cloud Management Console is quite a nice tool that we have control over the App Service infrastructure and even with just one click we can connect via RDP to Publisher:

 

To create web, API, and Azure Functions apps, you must use the tenant portal (eg. https://portal.local.azurestack.external/) not adminportal.

Azure Stack – App Service install problems

Jeżeli podczas instalacji App Service w Azure Stack napotkamy na problemy w szczególności w fazie Deploy App Service, jak poniżej:

Proponuje:

  1. Przejść do Resource Grupy zawierającej App Service w ASDK będzie to AppService.local i w Activity Log sprawdzić, jaki mieliśmy problem.

  2. Zazwyczaj będzie to problem z maszynami wirtualnymi CN0-VM lub CN1-VM, przechodzimy do nich, i w Activity Log sprawdzamy błędy:

  3. Bardziej znaczące logi można uzyskać logując się do tej maszyny za pomocą RDP – wcześniej odpowiednio konfigurując Network Security Group, tak aby przepuścić połączenia RDP i znajdują się one w:

    C:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension\1.9.1\Status\0.status

  4. Proponuje sprawdzić z tej maszyny czy działa połączenie do bazy danych, która dedykowaliśmy dla App Service za pomocą (oczywiście adres bazy i port podaje jaki przykład):

    Test-NetConnection -ComputerName appservicesql.local.cloudapp.azurestack.external -port 1433

  5. Uruchamiamy Web Cloud Management Console (jest na pulpicie odpowiedni skrót) i potwierdzamy , iż Controller i Management działa prawidłowo:
  6. Otwieramy plik 0.status do edycji i podmieniamy jego zawartość na sukces (w przypadku, kiedy były to błędy typu time-out):[{“status”:{“code”:0,”formattedMessage”:{“lang”:”en-US”,”message”:”Finished executing command”},”name”:”powershell.exe -ExecutionPolicy Unrestricted -Command .\\OnStartAzureVirtualMachineController.ps1″,”operation”:”Command Execution Finished”,”status”:”success”,”substatus”:[{“code”:0,”formattedMessage”:{“lang”:”en-US”,”message”:”Waiting for servers to be ready…\\n2017.05.26 04:59:26 —- Servers are ready!\\n2017.05.26 04:59:27 —- All servers are ready!\\n2017.05.26 04:59:27 —- App Service controller installation and configuration has completed successfully.”},”name”:”StdOut”,”status”:”success”},{“code”:0,”formattedMessage”:{“lang”:”en-US”,”message”:””},”name”:”StdErr”,”status”:”success”}]},”timestampUTC”:”\/Date(1495774767271)\/”,”version”:”1″}]
  7. Wciskamy Retry przy Deploy App Service.

If during the installation of the App Service in Azure Stack we encounter problems in the Deploy App Service phase, as below:

My suggestion is:

  1. Go to the Resource Group containing the App Service (ASDK: AppService.local) and in Activity Log check what problem we had.

  2. Usually this will be a problem with CN0-VM or CN1-VM virtual machines, go to them, and we check errors in Activity Log:

  3. More significant logs can be obtained by logging in to this machine using RDP – previously configuring the Network Security Group to pass the RDP connections. Logs are in:

    C:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension\1.9.1\Status\0.status

  4. I suggest to the connection to the database – example:
    Test-NetConnection -ComputerName appservicesql.local.cloudapp.azurestack.external -port 1433
  5. We can start the Web Cloud Management Console (there is a shortcut on the desktop) and confirm that the Controller and Management are working properly:
  6. Open 0.status and edit the content to success one (if there was time-out error):[{“status”:{“code”:0,”formattedMessage”:{“lang”:”en-US”,”message”:”Finished executing command”},”name”:”powershell.exe -ExecutionPolicy Unrestricted -Command .\\OnStartAzureVirtualMachineController.ps1″,”operation”:”Command Execution Finished”,”status”:”success”,”substatus”:[{“code”:0,”formattedMessage”:{“lang”:”en-US”,”message”:”Waiting for servers to be ready…\\n2017.05.26 04:59:26 —- Servers are ready!\\n2017.05.26 04:59:27 —- All servers are ready!\\n2017.05.26 04:59:27 —- App Service controller installation and configuration has completed successfully.”},”name”:”StdOut”,”status”:”success”},{“code”:0,”formattedMessage”:{“lang”:”en-US”,”message”:””},”name”:”StdErr”,”status”:”success”}]},”timestampUTC”:”\/Date(1495774767271)\/”,”version”:”1″}]
  7. Press Retry in Deploy App Service.

Identyfikacja błędów w logu instalacyjnym appservice_* / Errors Identyfication in appservice_*:

“code”: “ComponentStatus/StdErr/Succeeded”,

“level”: “Info”,

“displayStatus”: “Provisioning Succeeded”,

“message”: “Wait for servers has timed out\\nAt C:\\Packages\\Plugins\\Microsoft.Compute.CustomScriptExtension\\1.9.1\\Downloads\\\\n0\\Common\\common.ps1:457 char:13\\n+ throw New-Object System.TimeoutException \”Wait for server …\\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\n + CategoryInfo : OperationStopped: (:) [], TimeoutException\\n + FullyQualifiedErrorId : Wait for servers has timed out\\n \\nC:\\Packages\\Plugins\\Microsoft.Compute.CustomScriptExtension\\1.9.1\\Downloads\\0\\O\\nnStartAzureVirtualMachineController.ps1 : Error while waiting for server to \\nbecome ready. Exit code: 1.\\nAt line:1 char:1\\n+ .\\OnStartAzureVirtualMachineController.ps1 -controllerIndex 0 -feed h …\\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\n + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExcep \\n tion\\n + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio \\n n,OnStartAzureVirtualMachineController.ps1\\n ”

}

],

“statuses”: [

{

“code”: “ProvisioningState/failed/1”,

“level”: “Error”,

“displayStatus”: “Provisioning failed”,

“message”: “Finished executing command”

}

]

}

],

“value”: [

{

“id”: “/subscriptions/ff03660a-cdb3-4a7d-aac9-d119df98aebe/resourceGroups/AppService.local/providers/Microsoft.Resources/deployments/AppService.DeployCloud/operations/D8BBEDE893A93B51”,

“operationId”: “D8BBEDE893A93B51”,

“properties”: {

“provisioningOperation”: “Create”,

“provisioningState”: “Failed”,

“timestamp”: “2018-12-29T13:05:33.2421039Z”,

“duration”: “PT1M23.5284416S”,

“trackingId”: “e3607fe5-a29d-474a-a1c0-91c02719ee72”,

“serviceRequestId”: “3b1547a6-4eba-4ab5-8202-670f250698ab”,

“statusCode”: “Conflict”,

“statusMessage”: {

“status”: “Failed”,

“error”: {

“code”: “ResourceDeploymentFailure”,

“message”: “The resource operation completed with terminal provisioning state ‘Failed’.”,

“details”: [

{

“code”: “VMExtensionProvisioningError”,

“message”: “VM has reported a failure when processing extension ‘OnStart’. Error message: Finished executing command”

}

]

}

},

“targetResource”: {

“id”: “/subscriptions/ff03660a-cdb3-4a7d-aac9-d119df98aebe/resourceGroups/AppService.local/providers/Microsoft.Compute/virtualMachines/CN0-VM/extensions/OnStart”,

“resourceType”: “Microsoft.Compute/virtualMachines/extensions”,

“resourceName”: “CN0-VM/OnStart”

}

}

},

{

“id”: “/subscriptions/ff03660a-cdb3-4a7d-aac9-d119df98aebe/resourceGroups/AppService.local/providers/Microsoft.Resources/deployments/AppService.DeployCloud/operations/6A1B090ABDF12ECD”,

“operationId”: “6A1B090ABDF12ECD”,

“properties”: {

“provisioningOperation”: “Create”,

“provisioningState”: “Succeeded”,

“timestamp”: “2018-12-29T11:40:15.9086899Z”,

“duration”: “PT1M3.229514S”,

“trackingId”: “d094b163-33bf-45d6-99a9-5bc4e3d3889a”,

“serviceRequestId”: “f3b8fecc-740c-4224-9615-36d8036af988”,

“statusCode”: “OK”,

“targetResource”: {

“id”: “/subscriptions/ff03660a-cdb3-4a7d-aac9-d119df98aebe/resourceGroups/AppService.local/providers/Microsoft.Compute/virtualMachines/CN1-VM/extensions/OnStart”,

“resourceType”: “Microsoft.Compute/virtualMachines/extensions”,

“resourceName”: “CN1-VM/OnStart”

}

}

[{“version”:”1″,”timestampUTC”:”2018-12-29T13:03:34.4429755Z”,”status”:{“name”:”SecureCommand_0″,”operation”:”Command Execution Finished”,”status”:”error”,”code”:1,”formattedMessage”:{“lang”:”en-US”,”message”:”Finished executing command”},”substatus”:[{“name”:”StdOut”,”status”:”success”,”code”:0,”formattedMessage”:{“lang”:”en-US”,”message”:”—- Waiting for servers to be ready…\\n2018.12.29 11:58:31 —- Waiting for servers to be ready…\\n2018.12.29 11:59:31 —- Waiting for servers to be ready…\\n2018.12.29 12:00:31 —- Waiting for servers to be ready…\\n2018.12.29 12:01:31 —- Waiting for servers to be ready…\\n2018.12.29 12:02:31 —- Waiting for servers to be ready…\\n2018.12.29 12:03:31 —- Waiting for servers to be ready…\\n2018.12.29 12:04:31 —- Waiting for servers to be ready…\\n2018.12.29 12:05:31 —- Waiting for servers to be ready…\\n2018.12.29 12:06:31 —- Waiting for servers to be ready…\\n2018.12.29 12:07:31 —- Waiting for servers to be ready…\\n2018.12.29 12:08:31 —- Waiting for servers to be ready…\\n2018.12.29 12:09:31 —- Waiting for servers to be ready…\\n2018.12.29 12:10:31 —- Waiting for servers to be ready…\\n2018.12.29 12:11:31 —- Waiting for servers to be ready…\\n2018.12.29 12:12:31 —- Waiting for servers to be ready…\\n2018.12.29 12:13:31 —- Waiting for servers to be ready…\\n2018.12.29 12:14:31 —- Waiting for servers to be ready…\\n2018.12.29 12:15:31 —- Waiting for servers to be ready…\\n2018.12.29 12:16:31 —- Waiting for servers to be ready…\\n2018.12.29 12:17:31 —- Waiting for servers to be ready…\\n2018.12.29 12:18:31 —- Waiting for servers to be ready…\\n2018.12.29 12:19:31 —- Waiting for servers to be ready…\\n2018.12.29 12:20:31 —- Waiting for servers to be ready…\\n2018.12.29 12:21:31 —- Waiting for servers to be ready…\\n2018.12.29 12:22:31 —- Waiting for servers to be ready…\\n2018.12.29 12:23:31 —- Waiting for servers to be ready…\\n2018.12.29 12:24:31 —- Waiting for servers to be ready…\\n2018.12.29 12:25:31 —- Waiting for servers to be ready…\\n2018.12.29 12:26:31 —- Waiting for servers to be ready…\\n2018.12.29 12:27:31 —- Waiting for servers to be ready…\\n2018.12.29 12:28:31 —- Waiting for servers to be ready…\\n2018.12.29 12:29:31 —- Waiting for servers to be ready…\\n2018.12.29 12:30:31 —- Waiting for servers to be ready…\\n2018.12.29 12:31:31 —- Waiting for servers to be ready…\\n2018.12.29 12:32:31 —- Waiting for servers to be ready…\\n2018.12.29 12:33:31 —- Waiting for servers to be ready…\\n2018.12.29 12:34:31 —- Waiting for servers to be ready…\\n2018.12.29 12:35:31 —- Waiting for servers to be ready…\\n2018.12.29 12:36:31 —- Waiting for servers to be ready…\\n2018.12.29 12:37:32 —- Waiting for servers to be ready…\\n2018.12.29 12:38:32 —- Waiting for servers to be ready…\\n2018.12.29 12:39:32 —- Waiting for servers to be ready…\\n2018.12.29 12:40:32 —- Waiting for servers to be ready…\\n2018.12.29 12:41:32 —- Waiting for servers to be ready…\\n2018.12.29 12:42:32 —- Waiting for servers to be ready…\\n2018.12.29 12:43:32 —- Waiting for servers to be ready…\\n2018.12.29 12:44:32 —- Waiting for servers to be ready…\\n2018.12.29 12:45:32 —- Waiting for servers to be ready…\\n2018.12.29 12:46:32 —- Waiting for servers to be ready…\\n2018.12.29 12:47:32 —- Waiting for servers to be ready…\\n2018.12.29 12:48:32 —- Waiting for servers to be ready…\\n2018.12.29 12:49:32 —- Waiting for servers to be ready…\\n2018.12.29 12:50:32 —- Waiting for servers to be ready…\\n2018.12.29 12:51:32 —- Waiting for servers to be ready…\\n2018.12.29 12:52:32 —- Waiting for servers to be ready…\\n2018.12.29 12:53:32 —- Waiting for servers to be ready…\\n2018.12.29 12:54:32 —- Waiting for servers to be ready…\\n2018.12.29 12:55:32 —- Waiting for servers to be ready…\\n2018.12.29 12:56:32 —- Waiting for servers to be ready…\\n2018.12.29 12:57:32 —- Waiting for servers to be ready…\\n2018.12.29 12:58:32 —- Waiting for servers to be ready…\\n2018.12.29 12:59:32 —- Waiting for servers to be ready…\\n2018.12.29 01:00:32 —- Waiting for servers to be ready…\\n2018.12.29 01:01:32 —- Waiting for servers to be ready…\\n2018.12.29 01:02:32 —- Waiting for servers to be ready…\\n2018.12.29 01:03:33 —- Error while waiting for server to become ready. Exit code: 1.\\n\\n”}},{“name”:”StdErr”,”status”:”success”,”code”:0,”formattedMessage”:{“lang”:”en-US”,”message”:”Wait for servers has timed out\\nAt C:\\Packages\\Plugins\\Microsoft.Compute.CustomScriptExtension\\1.9.1\\Downloads\\\\n0\\Common\\common.ps1:457 char:13\\n+ throw New-Object System.TimeoutException \”Wait for server …\\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\n + CategoryInfo : OperationStopped: (:) [], TimeoutException\\n + FullyQualifiedErrorId : Wait for servers has timed out\\n \\nC:\\Packages\\Plugins\\Microsoft.Compute.CustomScriptExtension\\1.9.1\\Downloads\\0\\O\\nnStartAzureVirtualMachineController.ps1 : Error while waiting for server to \\nbecome ready. Exit code: 1.\\nAt line:1 char:1\\n+ .\\OnStartAzureVirtualMachineController.ps1 -controllerIndex 0 -feed h …\\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\n + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExcep \\n tion\\n + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio \\n n,OnStartAzureVirtualMachineController.ps1\\n “}}]}}]

Azure Active Directory – Synchronizacja pojedynczego konta, Sprawdzenie synchronizacji, Synchronization of a single account, Checking the synchronization

Jeżeli chcemy sprawdzić stan synchronizacji lub synchronizować jedno konto z Lokalnego Active Directory z Azure Active Directory, logujemy się na maszynę gdzie mamy zainstalowany Azure Ad Connect i uruchamiamy Synchronization Service (“C:\Program Files\Microsoft Azure AD Sync\UIShell\miisclient.exe”).

Widzimy tutaj wszystkie uruchomienia synchronizacji i ewentualnie możemy wejść w detale, aby poznać co kiedy się synchronizowało wraz z ewentualnymi błędami.

Jeżeli chcemy dokonać synchronizacji tylko jednego obiektu np. w celu sprawdzenia błędów, bądź aktualizacji atrybutów, należy go wyszukać – jak poniżej:

Następnie wybieramy Preview, Generate Preview gdzie możemy zapoznać się z ewentualnymi problemami, błędami i ewentualnie Commit Preview i wówczas następuje synchronizacja obiektu.

Na marginesie wspomnę, iż kilka razy obiekt w wypadku użycia PowerShellowej komendy Start-ADSyncSyncCycle -PolicyType Delta nie synchronizował się – albo był w “dziwnym stanie”, a zastosowanie powyższej procedury rozwiązało problem.


If we want to check the synchronization status or synchronize one account from the Local Active Directory with Azure Active Directory, log on to the machine where we have Azure Ad Connect installed and run the Synchronization Service (“C:\Program Files\Microsoft Azure AD Sync\UIShell\miisclient.exe”).

We can see here all the synchronization events and eventually we can go into details to find out what happened when it synchronized with possible errors.

We can synchronize only one object, for example to check for errors or update attributes, you should search for it – as below:

Then choose Preview, Generate Preview where we can see any problems, errors and finally we can press Commit Preview to synchronize the object.

By the way, I will mention that in this way I synchronize the objects that was in a “strange state”, and Start-ADSyncSyncCycle -PolicyType Delta do not fix them.

Azure Stack – ‘Name’ cannot be found on this object. or The SafeOS must be running Windows Server 2016 or Windows 10

Jeżeli podczas uruchamiania pliku .\asdk-installer.ps1 natrafimy na poniższy błąd:

The property ‘Name’ cannot be found on this object. Verify that the property exists and can be set.
At C:\AzureStack_Installer\asdk-installer.ps1:1755 char:1
+ $Runspace_Jobs_Properties.Name = “Jobs”
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException

Oznacza to iż, nie mamy zainstalowanego Windows Management Framework 5.1 – wystarczy go zainstalować i uruchomić instalacje raz jeszcze.

W przypadku błędu:

F_Initialize : The SafeOS must be running Windows Server 2016 or Windows 10 to use the ASDK Installer. Consider upgrading
the SafeOS or use PowerShell to install the ASDK
https://docs.microsoft.com/en-us/azure/azure-stack/asdk/asdk-deploy-powershell
At C:\AzureStack_Installer\asdk-installer.ps1:2802 char:1
+ F_Initialize

Komentujemy linię 1853 i wówczas Azure Stack możemy zainstalować nawet z Windows 8.1 lub Windows 2012 R2.


During running .\asdk-installer.ps1 in case of error:

The property ‘Name’ cannot be found on this object. Verify that the property exists and can be set.
At C:\AzureStack_Installer\asdk-installer.ps1:1755 char:1
+ $Runspace_Jobs_Properties.Name = “Jobs”
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException

It means that we have not installed Windows Management Framework 5.1 – so please install it.

In case of error:

F_Initialize : The SafeOS must be running Windows Server 2016 or Windows 10 to use the ASDK Installer. Consider upgrading
the SafeOS or use PowerShell to install the ASDK
https://docs.microsoft.com/en-us/azure/azure-stack/asdk/asdk-deploy-powershell
At C:\AzureStack_Installer\asdk-installer.ps1:2802 char:1
+ F_Initialize

Please comment line 1853 then we can install Azure Stack from Windows 8.1 or Windows 2012 R2.

Uzyskanie praw Global Administratora / How to get Global Administrator rights

Ze względu na specyfikę działania serwisów chmurowych Microsoft oraz samego działania Azure Active Directory może się zdarzyć, iż będziemy mieli dostęp do usługi katalogowej w Azure, w której nie mamy praw Global Admina. O ile w pierwszym momencie korzystania zwłaszcza z obcych usług, może nam to nie przeszkadzać, ale jeżeli będziemy adoptować nowe usługi chmurowe Microsoft okaże się to uciążliwe, a może i niezbędne – np. przy zarządzaniu kontem partnerskim Microsoft. Przy okazji warto zapoznać się z tym wpisem opisującym doświadczalnie zachowanie się Azure Active Directory.

Jak więc uzyskać uprawnienia Global Administratora:

  1. Logujemy się do portal.azure.com i przechodzimy do Azure Acctive Directory i All users. Jak widzimy nie mamy żadnego użytkownika z uprawnieniami Global Administratora.
  2. Zalogujemy się do strony https://powerbi.com/ i wybierzmy START FREE i TRY FREE
  3. Tutaj przy logowaniu prawdopodobnie wyświetli się opcja, iż mamy już konto w Azure Active Directory dlatego zalogujmy się do tego konta, ale już poprzez witrynę office.com
  4. Po wciśnięciu Admin powinniśmy otrzymać screen jak poniżej:
  5. Tutaj już sprawa prosta wciskamy opcje chcę być administratorem i dalej prawdopodobnie będziemy musieli weryfikować fakt bycia administratorem domeny internetowej, a więc będziemy musieli do rekordów domeny dodać rekord TXT. Gdy tylko to zrobimy staniemy się Administratorem Globalnym, wystarczy wylogować się i zalogować ponownie.


    Due to the specifics of the operation of Microsoft cloud services and the Azure Active Directory itself, it may happen that we will have access to theAzure Active Directory, in which we do not have Global Admin rights. While in the first moment of using especially foreign services, it may not disturb us, but if we adopt new Microsoft cloud services, it will be cumbersome, and sometime it is necessary to have Global Administrator Rights – for an example when managing a Microsoft partner account. By the way, please also read this article.

    So how do you get the Global Administrator privileges:

    1. Log to the portal.azure.com  and go to Azure Acctive Directory and All users. As we see we do not have Global Administrator Rights..
    2. Log to https://powerbi.com/ and choose START FREE and TRY FREE
    3. Here you will probably see the message that you already have an account in Azure Active Directory, so log in to this account, but now via office.com
    4. After pressing Admin, we should get a screen like this (Would you like to become administrator):
    5. We are almost at home just presy Yes and you will probably have to verify the internet domain by adding TXT record to the domain records. As soon as you do, you will become a Global Administrator, simply log out and log in again.

Powyższa procedura przydatna podczas napotkania komunikatów/ The above procedure is useful when encountering messages:

We have moved MPN membership management from Partner Membership Center (PMC) to the Partner Center—the single destination to manage your business relationship with Microsoft. After you move, you’ll maintain existing benefits and have access to additional tools such as customer referrals and go-to-market services​

To continue using your membership benefits, you need to move your account now.

Welcome to Partner Center!
To make it easier for you to manage and grow your business, we’re consolidating features and functions that are currently spread across separate sites onto one platform, the Microsoft Partner Center portal.
To successfully move your data from Partner Membership Center and create an account for Partner Center, you’ll need to have on hand the following information. You may want to take a few minutes to gather these items before you get started:
Global administrator credentials for your work account
You’ll need to provide the user name and password you use to sign into Office 365, Microsoft Azure, or Microsoft Dynamics CRM. If you don’t have a work account, you can create one during the enrollment process.
Your organization’s legal business name, address, primary contact, and support details
We need this information to confirm that your organization has an established profile with Microsoft and that you are authorized to act on its behalf.
Authority to sign the agreement
Ensure that you are authorized to sign legal agreements on your organization’s behalf as you’ll be asked to do so during the enrollment process.
We’ll verify the information you provided.

Azure Stack – step 60.120 failed, name could not be resolved login.microsoftonline.com, problemy z siecią/network problems

W czasie wdrażania Azure Stack możemy spotkać błąd typu:

Invoke-EceAction : Action: Invocation of step 60.120 failed. Stopping invocation of action plan.

Pierwszym krokiem będzie ponowne uruchomienie instalatora:

cd C:\CloudDeployment\Setup
PS C:\CloudDeployment\Setup> .\InstallAzureStackPOC.ps1 -rerun

Po-czym zapewne zobaczymy:

Invoke-EceAction : Action: Invocation of step 60 failed. Stopping invocation of action plan.
At C:\CloudDeployment\Setup\DeploySingleNode.ps1:809 char:5
+ Invoke-EceAction -RolePath $masterRole -ActionType $actionPlan @d …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Invoke-EceAction], ActionExecutionException
+ FullyQualifiedErrorId : Unspecified error,CloudEngine.Cmdlets.InvokeCmdlet

Bardzo często świadczy, to o problemach sieciowych – zwłaszcza, że instalator w tym zakresie nie jest precyzyjny, a my nie-czytając dokumentacji podajemy błędne parametry sieci dla BGPNAT.

Jeżeli przejdziemy troszkę do góry w logu zobaczymy prawdopodobnie problem z rozwiązywaniem nazwy login.microsoftonline.com

 

Możemy jeszcze zweryfikować i sprawdzić wydając polecenie:

PS C:\CloudDeployment\Setup> ping login.microsoftonline.com
Ping request could not find host login.microsoftonline.com. Please check the name and try again.

 

Jak rozwiązać tego typu problem.

Sprawdzić czy prawidłowo ustawiony jest forwarder w DNS na maszynie AzS-DC01 (Uruchamiamy Hyper-V managera i możemy się do niej zalogować używając loginu azurestack\AzureStackAdmin). Niestety jest to maszyna Windows Server Core więc działamy z PowerShella.
Jeżeli tego nie lubimy na naszej głównej maszynie (tej uruchomionej z CloudBuilder.vhdx) uruchamiamy mmc i dodajemy przystawkę DNS i łączymy się z AzS-DC01.azurestack.local i sprawdzamy ustawienia DNS.

Jak widać ustawione mamy, aby w przypadku braku połączenia do Forwardera używał RootHintsów, więc raczej to nie jest to, chyba, że mamy zablokowane odpytywanie zewnętrznych DNSów (UDP/TCP port 53).

Bardziej prawdopodobne, że mamy źle skonfigurowanego NATa na maszynie AzS-BGPNAT01 – w moim przypadku po wydaniu ipconfig oczom ujrzał mi się wpis:

No właśnie – mamy dla interface zewnętrznego przyporządkowany adres 172.25.229.0 !!! Założeniem było, że nasza sieć będzie miała adres 172.25.229.0/24, a pierwszy host to 172.25.229.1. Tak więc musimy zmienić nie tylko adres IP karty Ethernet, ale także reguły NATowania – jak to robimy:

get-netnat #wyświetlamy NATa
Get-NetNat|Remove-NetNat #musimy skasować NATa, bo nie możemy rekonfigurować adresu zewnętrznego
Netsh interface ipv4 set address “ethernet” static 172.25.229.1 255.255.255.0 172.25.229.254 #Ustawiamy nowy adres ip, pamiętajmy, aby to robić po skasowaniu NATa – w przyciwnym wypadku nam się nie uda skasować NATa.
New-NetNat -Name “BGPNAT” -ExternalIPInterfaceAddressPrefix 172.16.229.0/24 #Robimy nowego NATa
Add-NetNatExternalAddress -NatName “BGPNAT” -IPaddress 172.25.229.1 -PortStart 5000 -PortEnd 49151

I od tego momentu powinniśmy móc wykonać ping na 8.8.8.8, a z innych hostów powinićmy móc wykonać ping dns.pl

Powyższej procedury można używać też do zmieniania zewnętrznego adresu ip – aczkolwiek nie jest to cała procedura.


During the implementation of Azure Stack, we can encounter an error of the type:

Invoke-EceAction : Action: Invocation of step 60.120 failed. Stopping invocation of action plan.

The first step will be to restart the installer:

cd C:\CloudDeployment\Setup
PS C:\CloudDeployment\Setup> .\InstallAzureStackPOC.ps1 -rerun

That propably finish with this:

Invoke-EceAction : Action: Invocation of step 60 failed. Stopping invocation of action plan.
At C:\CloudDeployment\Setup\DeploySingleNode.ps1:809 char:5
+ Invoke-EceAction -RolePath $masterRole -ActionType $actionPlan @d …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Invoke-EceAction], ActionExecutionException
+ FullyQualifiedErrorId : Unspecified error,CloudEngine.Cmdlets.InvokeCmdlet

It seems to be a network problem – especially with configuration of BGPNAT and we will probaly find in our output something similar to “could not be resolved login.microsoftonline.com”.

 

We can verify network problems with:

PS C:\CloudDeployment\Setup> ping login.microsoftonline.com
Ping request could not find host login.microsoftonline.com. Please check the name and try again.

 

How to resolve this type of problem.

Check if the forwarder is correctly set in DNS on the AzS-DC01 machine (We can run the Hyper-V manager and we can log in to it using the azurestack\AzureStackAdmin login). Unfortunately, this is a Windows Server Core machine, so we have to use PowerShell.
If you do not like it on our main machine (this one launched from CloudBuilder.vhdx), run mmc and add the DNS snap-in and connect to AzS-DC01.azurestack.local and check the DNS settings.

 

As you can see, we use RootHints in the absence of connection to the Forwarder, so this is probably not the case, unless we have blocked external DNS polling (UDP / TCP port 53).

More likely, we have a wrongly configured NAT on the AzS-BGPNAT01 machine – in my case, after the release of ipconfig, I saw an entry:

 

We have an address for the external interface 172.25.229.0 !!! The assumption was that our network should have the address 172.25.229.0/24, and the first host is 172.25.229.1. So we have to change not only the IP address of the Ethernet card, but also the NAT rule – how we do it:

get-netnat #display NAT
Get-NetNat|Remove-NetNat #we need to delete NAT – we can not reconfigure external address
Netsh interface ipv4 set address “ethernet” static 172.25.229.1 255.255.255.0 172.25.229.254 #Set a new ip address, in order to delete NAT the adress should match.
New-NetNat -Name “BGPNAT” -ExternalIPInterfaceAddressPrefix 172.16.229.0/24 #create a new NATa
Add-NetNatExternalAddress -NatName “BGPNAT” -IPaddress 172.25.229.1 -PortStart 5000 -PortEnd 49151

 And from that moment we should be able to ping on 8.8.8.8, and from other hosts we should be able to ping dns.pl.

The above procedure can also be used to change the external IP address – although this is not the entire procedure.

 

Konfiguracja uwierzytelnienia z wykorzystaniem Azure Active Directory w Apache / Apache and Azure Active Directory OpenID – Oauth

Ostatnio nadarzyła mi się konieczność skonfigurowania uwierzytelnienia z wykorzystaniem Azure Active Directory w Apache. Na przykładzie CentOs podaje jak to zrobić z wykorzystaniem OpenID / Oauth.

Instalujemy Apche oraz przykładowe komponenty wykorzystywane do testów:

yum -y install httpd
yum -y install mod_ssl
yum -y install php
yum -y install mc

Startujemy Apache wraz z ustawieniem autostartu serwisu:

systemctl enable httpd.service
systemctl start httpd.service

Do /var/www/html/ wrzucami przykładową stronę w php:

<?php
phpinfo();
?>

Proponuje, zainstalować certyfikat SSL testowy z wykorzystaniem narzędzia http://ssl4ip.westeurope.cloudapp.azure.com/ oraz DigiCert Util, aby wyeksportować .pfx do .cer i .key. Wstawiamy certyfikat dla naszej strony, a następnie w tym samym pliku pośrednie centrum certyfikacji i klucz prywatny do odpowiednich plików:

vi /etc/pki/tls/private/localhost.key
vi /etc/pki/tls/certs/localhost.crt
service httpd restart

Na pierwsze testy włączamy uwierzytelnianie Basic:

cd /var/www/html
touch .htpasswd
htpasswd .htpasswd a
I podajemy hasło np. a

Kreujemy plik .htaccess:

vi /var/www/html/.htpasswd

o treści:

AuthType Basic
AuthName “Azure Active Directory”
AuthUserFile /var/www/html/.htpasswd
Require valid-user

Jeszcze musimy prze-konfigurować Apache, aby akceptował nadpisywanie zmian z plików .htaccess:

vi /etc/httpd/conf/httpd.conf

i zmieniamy wszędzie z AllowOverride none na AllowOverride All, a na koniec restartujemy Apache:

service httpd restart

Od tego momentu powinniśmy wejść na stronę np.: https://213-199-133-54.h.com.pl, gdzie 213.199.133.54 to ip naszego serwera z Apache – wykorzystujemy DNS i certyfikat z http://ssl4ip.westeurope.cloudapp.azure.com/.

Po podaniu loginu ja hasła powinniśmy dostać się do strony. To teraz trzeba prze-konfigurować funkcjonalność, tak aby do tego celu wykorzystywać Azure Active Directory.

Instalujemy pakiet mod_auth_openidc:

yum install mod_auth_openidc
repoquery -l mod_auth_openidc

w pliku (vi /etc/httpd/conf.d/auth_openidc.conf) dodajemy:

OIDCProviderMetadataURL https://login.microsoftonline.com/2f5c0b12-3c26-4d04-9c4f-22b2dc35c /v2.0/.well-known/openid-configuration
# OIDCRedirectURI is a vanity URL that must point to a path protected by this module but must NOT point to any content
OIDCRedirectURI https://213-199-133-54.h.com.pl/a
OIDCCryptoPassphrase random1234
OIDCClientID 5ed1690e-b7d1-48b8-9eae-bcad7ddad
OIDCClientSecret WGxILH2Rk2IgTx5YwYHH7Sxpit4yrUDTQ=

Gdzie:

2f5c0b12-3c26-4d04-9c4f-22b2dc35c – Id Tenant’u Azure Active Directory
https://213-199-133-54.h.com.pl/a – przekierowanie po powrocie – katalog, a nie musi istnieć, ale tutaj wrócimy np. z błędem uwierzytelnienia
5ed1690e-b7d1-48b8-9eae-bcad7ddad – Id Aplikacji z Azure Active Directory
WGxILH2Rk2IgTx5YwYHH7Sxpit4yrUDTQ= – secret – dodany w portalu w danej aplikacji.

Na zakończenie zmieniamy /var/www/html/.htaccess na:

AuthType openid-connect
Require valid-user

I wydajemy service httpd restart i uwierzytelnianie z wykorzystaniem Azure Active Directory już działa.

Możemy skonfigurować, że użytkownik musi mieć nadane uprawnienia, aby skorzystać z danej aplikacji.
Być może wkrótce Video Step by Step jak to wszystko zrobić, gdyż jeden obraz mówi więcej niż tysiące słów – a co dopiero Video.


Recently, I have to configure authentication using Azure Active Directory in Apache. How to do it using CentOs 7.5 using OpenID / Oauth.

First step is to install Apache and some other components:

yum -y install httpd
yum -y install mod_ssl
yum -y install php
yum -y install mc

Start Apache and set it to autostart:

systemctl enable httpd.service
systemctl start httpd.service

Put to /var/www/html/ sample webpage:

<?php
phpinfo();
?>

I suggest installing a test SSL certificate using the tool from http://ssl4ip.westeurope.cloudapp.azure.com/ and DigiCert Util to export .pfx to .cer / .key. We insert the certificate for our site and then in the same file the intermediate certificate and the private key to the appropriate files::

vi /etc/pki/tls/private/localhost.key
vi /etc/pki/tls/certs/localhost.crt
service httpd restart

At the beginning lets test with Basic Authentication:

cd /var/www/html
touch .htpasswd
htpasswd .htpasswd a

and provide password.

Please create .htaccess file:

vi /var/www/html/.htpasswd

with:

AuthType Basic
AuthName “Azure Active Directory”
AuthUserFile /var/www/html/.htpasswd
Require valid-user

Please reconfigure Apache:

vi /etc/httpd/conf/httpd.conf

replace everywhere from AllowOverride none to AllowOverride All, and restart Apache:

service httpd restart

From that moment, we should go to the site, for example: https://213-199-133-54.h.com.pl, where 213.199.133.54 is the IP of our server with Apache – we use DNS and the certificate from http: // ssl4ip. westeurope.cloudapp.azure.com/.

After entering the login password, we should get to the site. It is now necessary to reconfigure the functionality so that Azure Active Directory can be used for this purpose.

Please install mod_auth_openidc:

yum install mod_auth_openidc
repoquery -l mod_auth_openidc

Add to /etc/httpd/conf.d/auth_openidc.conf:

OIDCProviderMetadataURL https://login.microsoftonline.com/2f5c0b12-3c26-4d04-9c4f-22b2dc35c /v2.0/.well-known/openid-configuration
# OIDCRedirectURI is a vanity URL that must point to a path protected by this module but must NOT point to any content
OIDCRedirectURI https://213-199-133-54.h.com.pl/a
OIDCCryptoPassphrase random1234
OIDCClientID 5ed1690e-b7d1-48b8-9eae-bcad7ddad
OIDCClientSecret WGxILH2Rk2IgTx5YwYHH7Sxpit4yrUDTQ=

Where:

2f5c0b12-3c26-4d04-9c4f-22b2dc35c – Azure Azctive Directory Tenant ID
https://213-199-133-54.h.com.pl/a – redirection on the return – a directory, does not have to exist, but here we will return, eg with an authentication error
5ed1690e-b7d1-48b8-9eae-bcad7ddad – Application ID from Azure Active Directory
WGxILH2Rk2IgTx5YwYHH7Sxpit4yrUDTQ= – secret – added in the portal in the given application.

Modify /var/www/html/.htaccess to:

AuthType openid-connect
Require valid-user

And we release service httpd restart and authentication using Azure Active Directory is already working.

We can configure that the user must be granted permission to use the application.
Maybe soon I will record Step by Step Video how to do it.


Some screenshot / Kilka obrazków poglądowych:

 

 

 

 

 

 

 

 

 

 

Testowi użytkownicy w nowej domenie Active Directory

Czasami musimy w celach testowych uruchomić Active Directory. Warto by zasilić nowo postawiona instancję kilkoma użytkownikami. W poniższym linku znajduje się skrypt, który bardzo ładnie to robi i zasysa użytkowników z pliku CSV, co może być przydatne również przy wgrywaniu realnych użytkowników do nowo postawionej domeny.


Sometimes we need to run Active Directory for testing purposes. It’s worth to fill the new instance up with several users. The following link contains a script that import users from a CSV file, which can also be useful when uploading real users to a newly created domain.

Script:

https://gallery.technet.microsoft.com/scriptcenter/Create-UsersGroup-for-9ee1de26

Android, iOS, oSX, Windows – Apache Cordova / Azure

Apache Cordova to narzędzie za pomocą, którego możemy za jednym zamachem pisać aplikacje (zazwyczaj biznesową) i kompilować ją dla:

  • android
  • browser
  • ios
  • osx
  • windows ~6.0.0

Mamy też wsparcie dla Azure.

Proces instalacji opisany jest na głównej stronie projektu, a stworzenie nowej aplikacji ogranicza się do wydania komend:

  • npm install -g cordova (instalacja)
  • cordova create MyApp
  • cd MyApp
  • cordova platform list
  • cordova platform add browser
  • cordova platform add android
  • cordova run browser

lub

  • cordova build android

 

Jeżeli naszą platformą wyjściową ma być Android wówczas należy postępować wg: https://cordova.apache.org/docs/en/8.x/guide/platforms/android/index.html

 

Z tego co zauważyłem lepiej radzi sobie wersja pod Linux (ze względu na wykorzystane produktu np. Gradle). Jeżeli nie mamy Linux’a pod ręką polecam zapoznać się z tym artykułem.

Najbardziej uciążliwą rzeczą jest ustawienie odpowiednich ścieżek i zmiennych środowiskowych (Błąd No installed build tools found. Install the Android build tools version 19.1.0 or higher). Poniżej lista dla Linux i Windows przy kompilacjach dla platformy Android i zainstalowaniu Android Studio dla użytkownika mf:

  • PATH=$PATH:/opt/jdk1.8.0_191/bin
  • PATH=$PATH:/opt/android-studio/bin
  • PATH=$PATH:/home/mf/Android/Sdk/platform-tools
  • PATH=$PATH:/home/mf/Android/Sdk/build-tools/28.0.3
  • PATH=$PATH:/home/mf/Android/Sdk/tools
  • PATH=$PATH:/home/mf/Android/Sdk/tools/bin
  • JAVA_HOME=/opt/jdk1.8.0_191/
  • export JAVA_HOME
  • ANDROID_HOME=/home/mf/Android/Sdk/
  • export ANDROID_HOME

 

  • Path=
  • C:\Users\mf\AppData\Local\Android\Sdk\build-tools\28.0.3
  • C:\jdk1.8.0_191\bin;C:\Program Files\nodejs\
  • C:\Program Files\Android\Android Studio\bin
  • C:\Users\mf\AppData\Local\Android\Sdk\tools
  • C:\Users\mf\AppData\Local\Android\Sdk\platform-tools
  • C:\Program Files\Android\Android Studio\bin
  • C:\Users\mf\AppData\Local\Android\Sdk\emulator
  • C:\Users\mf\AppData\Local\Android\Sdk\tools\bin
  • C:\Users\mf\AppData\Local\Android\Sdk\tools\proguard\bin
  • C:\Users\mf\scoop\shims;C:\Users\mf\AppData\Local\Microsoft\WindowsApps
  • C:\Users\mf\AppData\Roaming\npm
  • ANDROID_HOME=C:\Users\mf\AppData\Local\Android\Sdk
  • ANDROID_STUDIO=C:\Program Files\Android\Android Studio
  • APPDATA=C:\Users\mf\AppData\Roaming
  • JAVA_HOME=C:\jdk1.8.0_191

Jeżeli napotkamy na błędy:

Minimum supported Gradle version is 4.4. Current version is 4.1.

polecam skorzystać z wersji dla Linux, lub stosować ten artykuł.


Apache Cordova is a fantastic tool that can compile applications for:

  • android
  • browser
  • ios
  • X-axis
  • windows ~ 6.0.0

We also have Azure support:

The installation process is described on the main project page and the creation of a new application is limited to issuing following commands:

  • npm install -g cordova (instalacja)
  • cordova create MyApp
  • cd MyApp
  • cordova platform list
  • cordova platform add browser
  • cordova platform add android
  • cordova run browser

or

  • cordova build android

 

If our destination platform is Android we should follow: https://cordova.apache.org/docs/en/8.x/guide/platforms/android/index.html

I noticed, that the Linux version works better (due to the product used, eg Gradle). If we do not have Linux at hand, I recommend reading this post.

The most troublesome thing is to set the right environment paths and variables (error: No installed build tools found. Install the Android build tools version 19.1.0 or higher). Below is a list for Linux and Windows on the compilations for the Android platform and the installation of Android Studio for the mf user:

  • PATH=$PATH:/opt/jdk1.8.0_191/bin
  • PATH=$PATH:/opt/android-studio/bin
  • PATH=$PATH:/home/mf/Android/Sdk/platform-tools
  • PATH=$PATH:/home/mf/Android/Sdk/build-tools/28.0.3
  • PATH=$PATH:/home/mf/Android/Sdk/tools
  • PATH=$PATH:/home/mf/Android/Sdk/tools/bin
  • JAVA_HOME=/opt/jdk1.8.0_191/
  • export JAVA_HOME
  • ANDROID_HOME=/home/mf/Android/Sdk/
  • export ANDROID_HOME

 

  • Path=
  • C:\Users\mf\AppData\Local\Android\Sdk\build-tools\28.0.3
  • C:\jdk1.8.0_191\bin;C:\Program Files\nodejs\
  • C:\Program Files\Android\Android Studio\bin
  • C:\Users\mf\AppData\Local\Android\Sdk\tools
  • C:\Users\mf\AppData\Local\Android\Sdk\platform-tools
  • C:\Program Files\Android\Android Studio\bin
  • C:\Users\mf\AppData\Local\Android\Sdk\emulator
  • C:\Users\mf\AppData\Local\Android\Sdk\tools\bin
  • C:\Users\mf\AppData\Local\Android\Sdk\tools\proguard\bin
  • C:\Users\mf\scoop\shims;C:\Users\mf\AppData\Local\Microsoft\WindowsApps
  • C:\Users\mf\AppData\Roaming\npm
  • ANDROID_HOME=C:\Users\mf\AppData\Local\Android\Sdk
  • ANDROID_STUDIO=C:\Program Files\Android\Android Studio
  • APPDATA=C:\Users\mf\AppData\Roaming
  • JAVA_HOME=C:\jdk1.8.0_191

If we found this kind of errors:

Minimum supported Gradle version is 4.4. Current version is 4.1.

I suggest to use Linux version, or read these posts.

Remote Desktop to Linux

Na co dzień, na komputerze desktop pracuje używając systemu Windows – czasami jednak potrzebuje oprogramowanie, które działa (np. bezbłędnie) tylko na linux. O ile oprogramowanie to działa w powłoce (shell), wystarczy dostęp do dowolnego systemu Linux poprzez SSH i uruchomienie oprogramowania. Gorzej, gdy potrzebujemy Graficznego Interface Użytkownika (GUI). I tym razem Azure może przyjść nam z pomocą – wystarczy wdrożyć, np. Ubuntu 18.10 i następnie wydać następujące polecenia:

apt-get -y update
apt-get -y install tasksel
tasksel install ubuntu-desktop
apt-get -y install xrdp
systemctl enable xrdp
service xrdp stop
echo xfce4-session >~/.xsession
service xrdp start
service xrdp status

Od tego momentu możemy z Linux połączyć się graficznie za pomocą oprogramowania Remote Desktop.

Usually I am using Windows based desktop Sometime I need to run software that works (without errors) only on Linux. If the software works in the shell, all you need is access to any Linux system via SSH and run the software. Worse, when we need Graphical User Interface (GUI). Using Azure we can launch for an example, Ubuntu 18.10 and then issue the following commands:

apt-get -y update
apt-get -y install tasksel
tasksel install ubuntu-desktop
apt-get -y install xrdp
systemctl enable xrdp
service xrdp stop
echo xfce4-session> ~ /.xsession
service xrdp start
service xrdp status

From that moment, we can connect graphically with Linux using the Remote Desktop software.

Rozwiązywanie konfliktów synchronizacji AD Connect / Resolving AD Connect synchronization conflicts / ImmutableID

Jeżeli korzystamy z oprogramowania AD Connect do synchronizacji kont lokalnego Active Directory, a wcześniej mieliśmy założone jakiś konta w Azure Active Directory, wówczas wcześniej czy później spotkamy się z konfliktem założenia konta w Azure Active Directory na podstawie konta Active Directory. Zdarzy się to w przypadku, kiedy mamy identyczny UPN w Active Directory i azłożymy konto w Azure Active Directory o takim samym mailu, które będzie miało role Global Administratora. Wówczas AD Connect założy konto w domenie @onmicrosoft.com a do nazwy użytkownika doda kilka cyferek i będziemy mieli konta:

  • mariusz.ferdyn8858@mojadomena.onmicrosoft.com
  • mariusz.ferdyn@mojadomena.pl

Do połączenia (matchowania) kont Azure Active Directory I Active Directory służy atrybut ImmutableID. I mówiąc, krótko musimy ustawić ten atrybut dla już istniejącego konta w Azure Active Directory, poniższą procedurą:

  1. Przenieść użytkwonika w Active Directory do konteneru, który nie jest synchronizwany
  2. Dokonać synchronizacji (Start-ADSyncSyncCycle -PolicyType Delta)
  3. Wyświetlić ImmutableID poleceniem:
    get-MsolUser -ReturnDeletedUsers -UserPrincipalName mariusz.ferdyn8858@mojadomena.onmicrosoft.com|fl
  4. Usunąć użytkownika z Azure Active Directory
    get-MsolUser -ReturnDeletedUsers -UserPrincipalName mariusz.ferdyn8858@mojadomena.onmicrosoft.com|Remove-MsolUser -RemoveFromRecycleBin
  5. Dokonać synchronizacji (Start-ADSyncSyncCycle -PolicyType Delta)
  6. Wyświetlić parametry istniejącego użytkownika w Azure Active Directory
    get-MsolUser -ReturnDeletedUsers -UserPrincipalName mariusz.ferdyn@mojadomena.pl|fl
  7. Ustawić immutableid otzrymane z polecenia 3, poprzez:
    get-MsolUser -UserPrincipalName mariusz.ferdyn@mojadomenapl.pl|Set-MsolUser -ImmutableId “W7gqU22hws4tpsPw==”
  8. Dokonać synchronizacji (Start-ADSyncSyncCycle -PolicyType Delta)

Po powyższym konta powinny być zsynchronizowane prawidłowo, a sama metoda może być stosowana do migracji użytkowników między domenami.


If we use AD Connect software to synchronize Active Directory local accounts, and previously we had some accounts in Azure Active Directory, sooner or later we will meet with the conflict of setting up an account in Azure Active Directory based on the Active Directory account. This will happen if we have the same UPN in Active Directory and set up an account in Azure Active Directory with the same e-mail that have the role of Global Administrator. Then AD Connect will create an account in the @ onmicrosoft.com domain and add a few numbers to the username, so we will have accounts:

  • mariusz.ferdyn8858@mojadomena.onmicrosoft.com
  • mariusz.ferdyn@mojadomena.pl

The ImmutableID attribute is used to connect (match) Azure Active Directory and Active Directory accounts. To merge two accounts, we have to set this attribute for an existing account in Azure Active Directory, with the following procedure:

  1. Move the user in Active Directory to a container that is not synchronizing
  2. Synchronize (Start-ADSyncSyncCycle -PolicyType Delta)
  3. Display ImmutableID with the command:
    get-MsolUser -ReturnDeletedUsers -UserPrincipalName mariusz.ferdyn8858@mydomain.onmicrosoft.com|fl
  4. Remove the user from Azure Active Directory
    get-MsolUser -ReturnDeletedUsers -UserPrincipalName mariusz.ferdyn8858@mydomain.onmicrosoft.com|Remove-MsolUser -RemoveFromRecycleBin
  5. Synchronize (Start-ADSyncSyncCycle -PolicyType Delta)
  6. View the parameters of an existing user in Azure Active Directory
    get-MsolUser -ReturnDeletedUsers -UserPrincipalName mariusz.ferdyn@mydomain.com|fl
  7. Set the immutableid from the command 3, by:
    get-MsolUser -UserPrincipalName mariusz.ferdyn@mojadomenapl.pl|Set-MsolUser -ImmutableId “W7gqU22hws4tpsPw ==”
  8. Synchronize (Start-ADSyncSyncCycle -PolicyType Delta)

After the above, the accounts should be synchronized correctly, and the method can be used to migrate users between domains.

Install-Module : The term ‘Install-Module’ is not recognized as the name of a cmdlet – AzureRM, MSOnline

Jeżeli chcemy zainstalować moduł PowerShell do zarządzania np. Azure (AzureRM) na Windows 7, Windows 8, Windows 2008 R2, Windows 2012, Windows 2012R2 i w tym celu wydamy komendę:

Install-Module AzureRM

Zobaczymy błąd:

Install-Module : The term ‘Install-Module’ is not recognized as the name of a cmdlet, funce program. Check the spelling of the name, or if a path was included, verify that the path
At line:1 char:1
+ Install-Module AzureRM
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Install-Module:String) [], CommandNotFoundE + FullyQualifiedErrorId : CommandNotFoundException

 

Aby rozwiązać ten problem do niedawna trzeba było korzystać z Web Platform Installer. Jedną z trochę zapomnianych jest zainstalowanie PackageManagement PowerShell Modules. Po instalacji pakietu mamy dostęp do komendy ‘Install-Module’ i możemy zainstalować nie tylko AzureRM, jak również np. moduł MSOnline:

Install-Module MSOnline

 


 

If you want to install the PowerShell module for managing eg. Azure (AzureRM) on Windows 7, Windows 8, Windows 2008 R2, Windows 2012, Windows 2012R2 and for this purpose we will issue the command:

Install-Module AzureRM

We will see:

Install-Module : The term ‘Install-Module’ is not recognized as the name of a cmdlet, funce program. Check the spelling of the name, or if a path was included, verify that the path
At line:1 char:1
+ Install-Module AzureRM
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Install-Module:String) [], CommandNotFoundE + FullyQualifiedErrorId : CommandNotFoundException

 

To solve this problem we usually had to use the Web Platform Installer. But there is another option – just install PackageManagement PowerShell Modules. After installing the package we have access to the ‘Install-Module’ command and we can install not only AzureRM, but also for example the MSOnline module:

Install-Module MSOnline

 

Migracja z Modelu Klasycznego do Azure Resource Manager / Migration from the Classic Model to Azure Resource Manager

Mimo, iż Azure Resource Manager ma już ładnych kilka lat – zdarza się, iż zastajemy Subskrybcje, gdzie usługi wdrożone są w modelu Classic.

Poniższe kroki migrują Storage Account z Modelu klasycznego do ARM.

Login-AzureRmAccount

Register-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicInfrastructureMigrate

Get-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicInfrastructureMigrate #Wait for registered

Add-AzureAccount

Get-AzureSubscription

Select-AzureSubscription -SubscriptionId “subscription id”

Get-AzureStorageAccount

$storageAccountName=”imagesmf”

$validate=Move-AzureStorageAccount -Validate -StorageAccountName $storageAccountName -Verbose

$validate

$validate.ValidationMessages

Move-AzureStorageAccount -Prepare -StorageAccountName $storageAccountName

Move-AzureStorageAccount -Commit -StorageAccountName $storageAccountName #-Abort will cancel operation

 

Po migracji zasoby będą w Resource Group z suffixem -Migrated. A operacja ta jest niezbędna jeżeli chcemy migrować zasoby z jednej subskrypcji do innej.


Migration from the Classic Model to Azure Resource Manager

Everyone use Azure Resource Manager for several years, but it happens that some resources are still implemented in the Classic model. The following steps migrate the Storage Account from the Classic Model to ARM.

Login-AzureRmAccount

Register-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicInfrastructureMigrate

Get-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicInfrastructureMigrate #Wait for registered

Add-AzureAccount

Get-AzureSubscription

Select-AzureSubscription -SubscriptionId “subscription id”

Get-AzureStorageAccount

$storageAccountName=”imagesmf”

$validate=Move-AzureStorageAccount -Validate -StorageAccountName $storageAccountName -Verbose

$validate

$validate.ValidationMessages

Move-AzureStorageAccount -Prepare -StorageAccountName $storageAccountName

Move-AzureStorageAccount -Commit -StorageAccountName $storageAccountName #-Abort will cancel operation

After migration, the resources will be in the Resource Group with suffix -Migrated. And this operation is necessary if we want to migrate resources from one Subscription to another.


More info / Więcej informacji

«< 7 8 9 10 11 >
Projekt i wykonanie: Mobiconnect i fast-sms.net   |    Regulamin
Ta strona korzysta z ciasteczek aby świadczyć usługi na najwyższym poziomie. Dalsze korzystanie ze strony oznacza, że zgadzasz się na ich użycie.Zgoda

Added to Cart

Keep Shopping