Mulai menggunakan Kerangka Kerja Otomatisasi Penyebaran SAP

Mulai dengan cepat menggunakan Kerangka Kerja Otomatisasi Penyebaran SAP.

Prasyarat

Untuk mulai menggunakan Kerangka Kerja Otomatisasi Penyebaran SAP, Anda memerlukan:

  • Langganan Azure. Jika Anda tidak memiliki langganan Azure, Anda dapat membuat akun gratis.
  • Akun Pengguna SAP dengan izin untuk mengunduh perangkat lunak SAP di lingkungan Azure Anda. Untuk informasi selengkapnya tentang S-User, lihat SAP S-User.
  • Penginstalan Azure CLI .
  • User Assigned Identity (MS) atau perwakilan layanan untuk digunakan untuk penyebaran sarana kontrol.
  • User Assigned Identity (MS) atau perwakilan layanan A untuk digunakan untuk penyebaran zona beban kerja.
  • Kemampuan untuk membuat proyek Azure DevOps jika Anda ingin menggunakan Azure DevOps untuk penyebaran.

Beberapa prasyarat mungkin sudah diinstal di lingkungan penyebaran Anda. Azure Cloud Shell dan penyebar dilengkapi dengan Terraform dan Azure CLI yang diinstal.

Membuat Identitas yang ditetapkan pengguna

Kerangka kerja penyebaran otomatisasi SAP juga dapat menggunakan identitas yang ditetapkan pengguna (MSI) untuk penyebaran. Pastikan untuk menggunakan akun dengan izin untuk membuat identitas terkelola saat menjalankan skrip yang membuat identitas.

  1. Buat identitas terkelola.

    export    ARM_SUBSCRIPTION_ID="<subscriptionId>"
    export control_plane_env_code="LAB"
    
    az identity create --name ${control_plane_env_code}-Deployment-Identity --resource-group <ExistingResourceGroup>
    

    Tinjau output. Contohnya:

       {
         "clientId": "<appId>",
         "id": "<armId>",
         "location": "<location>",
         "name": "${control_plane_env_code}-Deployment-Identity",
         "principalId": "<objectId>",
         "resourceGroup": "<ExistingResourceGroup>",
         "systemData": null,
         "tags": {},
         "tenantId": "<TenantId>",
         "type": "Microsoft.ManagedIdentity/userAssignedIdentities"
       }
    
  2. Salin detail output.

    Output tersebut memetakan ke parameter berikut. Anda akan menggunakan parameter ini di langkah selanjutnya, dengan perintah otomatisasi.

    Nama input parameter Nama output
    app_id appId
    msi_id armId
    msi_objectid objectId
  3. Tetapkan peran Kontributor ke identitas.

    export appId="<appId>"
    
    az role assignment create --assignee $msi_objectid  --role "Contributor"  --scope /subscriptions/$ARM_SUBSCRIPTION_ID
    
  4. Secara opsional, tetapkan peran Administrator Akses Pengguna ke identitas.

    export appId="<appId>"
    
    az role assignment create --assignee $msi_objectid --role "User Access Administrator"  --scope /subscriptions/$ARM_SUBSCRIPTION_ID
    

Penting

Jika Anda tidak menetapkan peran Administrator Akses Pengguna ke identitas terkelola, Anda tidak dapat menetapkan izin menggunakan kerangka kerja otomatisasi.

Membuat pendaftaran aplikasi untuk aplikasi web

Kerangka kerja penyebaran otomatisasi SAP dapat memanfaatkan Azure App Service untuk mengonfigurasi file parameter tfvars.

  1. Buat pendaftaran aplikasi.

       $ApplicationName="<App Registration Name>"
       $MSI_objectId="<msi_objectid>"
    
        Write-Host "Creating an App Registration for" $ApplicationName -ForegroundColor Green
    
        if (Test-Path $manifestPath) { Write-Host "Removing manifest.json" ; Remove-Item $manifestPath }
        Add-Content -Path manifest.json -Value '[{"resourceAppId":"00000003-0000-0000-c000-000000000000","resourceAccess":[{"id":"e1fe6dd8-ba31-4d61-89e7-88639da4683d","type":"Scope"}]}]'
    
        $APP_REGISTRATION_ID = $(az ad app create --display-name $ApplicationName --enable-id-token-issuance true --sign-in-audience AzureADMyOrg --required-resource-access $manifestPath --query "appId" --output tsv)
    
        Write-Host "App Registration created with App ID: $APP_REGISTRATION_ID"
    
        Write-Host "Waiting for the App Registration to be created" -ForegroundColor Green
        Start-Sleep -s 20
    
        $ExistingData = $(az ad app list --all --filter "startswith(displayName, '$ApplicationName')" --query  "[?displayName=='$ApplicationName']| [0]" --only-show-errors) | ConvertFrom-Json
    
        $APP_REGISTRATION_OBJECTID = $ExistingData.id
    
        if (Test-Path $manifestPath) { Write-Host "Removing manifest.json" ; Remove-Item $manifestPath }
    
        Write-Host "Configuring authentication for the App Registration" -ForegroundColor Green
        az rest --method POST --uri "https://graph.microsoft.com/beta/applications/$APP_REGISTRATION_OBJECTID/federatedIdentityCredentials\" --body "{'name': 'ManagedIdentityFederation', 'issuer': 'https://login.microsoftonline.com/$ARM_TENANT_ID/v2.0', 'subject': '$MSI_objectId', 'audiences': [ 'api://AzureADTokenExchange' ]}"
    
        $API_URL="https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/~/ProtectAnAPI/appId/$APP_REGISTRATION_ID/isMSAApp~/false"
    
        Write-Host "The browser will now open, Please Add a new scope, by clicking the '+ Add a new scope link', accept the default name and click 'Save and Continue'"
        Write-Host "In the Add a scope page enter the scope name 'user_impersonation'. Choose 'Admins and Users' in the who can consent section, next provide the Admin consent display name 'Access the SDAF web application' and 'Use SDAF' as the Admin consent description, accept the changes by clicking the 'Add scope' button"
    
        Start-Process $API_URL
        Read-Host -Prompt "Once you have created and validated the scope, Press any key to continue"
    
    
    

Membuat perwakilan layanan

Kerangka kerja penyebaran otomatisasi SAP dapat menggunakan perwakilan layanan untuk penyebaran.

Saat Anda memilih nama untuk perwakilan layanan Anda, pastikan nama tersebut unik dalam penyewa Azure Anda. Pastikan untuk menggunakan akun dengan izin pembuatan perwakilan layanan saat menjalankan skrip.

  1. Buat perwakilan layanan dengan izin Kontributor.

    export    ARM_SUBSCRIPTION_ID="<subscriptionId>"
    export control_plane_env_code="LAB"
    
    az ad sp create-for-rbac --role="Contributor"  --scopes="/subscriptions/$ARM_SUBSCRIPTION_ID"   --name="$control_plane_env_code-Deployment-Account"
    

    Tinjau output. Contohnya:

    {
        "appId": "<AppId>",
        "displayName": "<environment>-Deployment-Account ",
        "name": "<AppId>",
        "password": "<AppSecret>",
        "tenant": "<TenantId>"
    }
    
  2. Salin detail output. Pastikan untuk menyimpan nilai untuk appId, , passworddan Tenant.

    Output tersebut memetakan ke parameter berikut. Anda akan menggunakan parameter ini di langkah selanjutnya, dengan perintah otomatisasi.

    Nama input parameter Nama output
    spn_id appId
    spn_secret password
    tenant_id tenant
  3. Secara opsional, tetapkan peran Administrator Akses Pengguna ke perwakilan layanan.

    export appId="<appId>"
    
    az role assignment create --assignee $appId --role "User Access Administrator"  --scope /subscriptions/$ARM_SUBSCRIPTION_ID
    

Penting

Jika Anda tidak menetapkan peran Administrator Akses Pengguna ke perwakilan layanan, Anda tidak dapat menetapkan izin menggunakan kerangka kerja otomatisasi.

Pemeriksaan pra-penerbangan

Anda dapat menggunakan skrip berikut untuk melakukan pemeriksaan pra-penerbangan. Skrip melakukan pemeriksaan dan pengujian berikut:

  • Memeriksa apakah perwakilan layanan memiliki izin yang benar untuk membuat sumber daya dalam langganan.
  • Memeriksa apakah perwakilan layanan memiliki izin Administrator Akses pengguna.
  • Membuat Azure Virtual Network.
  • Buat Azure Virtual Key Vault dengan titik akhir privat.
  • Buat berbagi NSF Azure Files.
  • Buat Azure Virtual Machine dengan disk data menggunakan Premium Storage v2.
  • Periksa akses ke URL yang diperlukan menggunakan komputer virtual yang disebarkan.

$sdaf_path = Get-Location
if ( $PSVersionTable.Platform -eq "Unix") {
    if ( -Not (Test-Path "SDAF") ) {
      $sdaf_path = New-Item -Path "SDAF" -Type Directory
    }
}
else {
    $sdaf_path = Join-Path -Path $Env:HOMEDRIVE -ChildPath "SDAF"
    if ( -not (Test-Path $sdaf_path)) {
        New-Item -Path $sdaf_path -Type Directory
    }
}

Set-Location -Path $sdaf_path

git clone https://github.com/Azure/sap-automation.git 

cd sap-automation
cd deploy
cd scripts

if ( $PSVersionTable.Platform -eq "Unix") {
./Test-SDAFReadiness.ps1
}
else {
.\Test-SDAFReadiness.ps1
}

Menggunakan Kerangka Kerja Otomatisasi Penyebaran SAP dari Layanan Azure DevOps

Menggunakan Azure DevOps menyederhanakan proses penyebaran. Azure DevOps menyediakan alur yang dapat Anda jalankan untuk melakukan penyebaran infrastruktur dan konfigurasi serta aktivitas penginstalan SAP.

Anda dapat menggunakan Azure Repos untuk menyimpan file konfigurasi Anda. Azure Pipelines menyediakan alur, yang dapat digunakan untuk menyebarkan dan mengonfigurasi infrastruktur dan aplikasi SAP.

Daftar untuk Layanan Azure DevOps

Untuk menggunakan Azure DevOps Services, Anda memerlukan organisasi Azure DevOps. Sebuah organisasi digunakan untuk menghubungkan kelompok proyek terkait. Gunakan akun kerja atau sekolah Anda untuk menyambungkan organisasi Anda secara otomatis ke ID Microsoft Entra Anda. Untuk membuat akun, buka Azure DevOps dan masuk atau buat akun baru.

Membuat lingkungan Kerangka Kerja Automasi Penyebaran SAP dengan Azure DevOps

Anda dapat menggunakan skrip berikut untuk melakukan penginstalan dasar Azure DevOps Services for SAP Deployment Automation Framework.

Buka PowerShell ISE dan salin skrip berikut dan perbarui parameter agar sesuai dengan lingkungan Anda.

    $Env:SDAF_ADO_ORGANIZATION = "https://dev.azure.com/ORGANIZATIONNAME"
    $Env:SDAF_ADO_PROJECT = "SAP Deployment Automation Framework"
    $Env:SDAF_CONTROL_PLANE_CODE = "MGMT"
    $Env:SDAF_WORKLOAD_ZONE_CODE = "DEV"
    $Env:SDAF_ControlPlaneSubscriptionID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    $Env:SDAF_WorkloadZoneSubscriptionID = "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"
    $Env:ARM_TENANT_ID="zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz"

    $UniqueIdentifier = Read-Host "Please provide an identifier that makes the service principal names unique, for instance a project code"

    $confirmation = Read-Host "Do you want to create a new Application registration (needed for the Web Application) y/n?"
    if ($confirmation -eq 'y') {
        $Env:SDAF_APP_NAME = $UniqueIdentifier + " SDAF Control Plane"
    }

    else {
      $Env:SDAF_APP_NAME = Read-Host "Please provide the Application registration name"
    }

    $confirmation = Read-Host "Do you want to create a new Service Principal for the Control plane y/n?"
    if ($confirmation -eq 'y') {
        $Env:SDAF_MGMT_SPN_NAME = $UniqueIdentifier + " SDAF " + $Env:SDAF_CONTROL_PLANE_CODE + " SPN"
    }
        else {
      $Env:SDAF_MGMT_SPN_NAME = Read-Host "Please provide the Control Plane Service Principal Name"
    }

    $confirmation = Read-Host "Do you want to create a new Service Principal for the Workload zone y/n?"
    if ($confirmation -eq 'y') {
        $Env:SDAF_WorkloadZone_SPN_NAME = $UniqueIdentifier + " SDAF " + $Env:SDAF_WORKLOAD_ZONE_CODE + " SPN"
    }
        else {
      $Env:SDAF_WorkloadZone_SPN_NAME = Read-Host "Please provide the Workload Zone Service Principal Name"
    }

    if ( $PSVersionTable.Platform -eq "Unix") {
        if ( Test-Path "SDAF") {
        }
        else {
            $sdaf_path = New-Item -Path "SDAF" -Type Directory
        }
    }
    else {
        $sdaf_path = Join-Path -Path $Env:HOMEDRIVE -ChildPath "SDAF"
        if ( Test-Path $sdaf_path) {
        }
        else {
            New-Item -Path $sdaf_path -Type Directory
        }
    }

    Set-Location -Path $sdaf_path

    if ( Test-Path "New-SDAFDevopsProject.ps1") {
        remove-item .\New-SDAFDevopsProject.ps1
    }

    Invoke-WebRequest -Uri https://raw.githubusercontent.com/Azure/sap-automation/main/deploy/scripts/New-SDAFDevopsProject.ps1 -OutFile .\New-SDAFDevopsProject.ps1 ; .\New-SDAFDevopsProject.ps1

Jalankan skrip dan ikuti instruksinya. Skrip membuka jendela browser untuk autentikasi dan untuk melakukan tugas di proyek Azure DevOps.

Anda dapat memilih untuk menjalankan kode langsung dari GitHub atau Anda dapat mengimpor salinan kode ke dalam proyek Azure DevOps Anda.

Untuk mengonfirmasi bahwa proyek telah dibuat, buka portal Azure DevOps dan pilih proyek. Pastikan bahwa repositori diisi dan alur dibuat.

Penting

Jalankan langkah-langkah berikut di stasiun kerja lokal Anda. Pastikan juga bahwa Anda memiliki Azure CLI terbaru yang diinstal dengan menjalankan az upgrade perintah .

Untuk informasi selengkapnya tentang cara mengonfigurasi Azure DevOps untuk Kerangka Kerja Otomatisasi Penyebaran SAP, lihat Mengonfigurasi Azure DevOps untuk Kerangka Kerja Otomatisasi Penyebaran SAP.

Membuat lingkungan Kerangka Kerja Automasi Penyebaran SAP tanpa Azure DevOps

Anda dapat menjalankan Kerangka Kerja Otomatisasi Penyebaran SAP dari komputer virtual di Azure. Langkah-langkah berikut menjelaskan cara membuat lingkungan.

Penting

Pastikan bahwa komputer virtual menggunakan identitas yang ditetapkan sistem atau ditetapkan pengguna dengan izin pada langganan untuk membuat sumber daya.

Pastikan komputer virtual memiliki prasyarat berikut yang terinstal:

  • git
  • jq
  • unzip
  • virtualenv (jika berjalan di Ubuntu)

Anda dapat menginstal prasyarat pada komputer virtual Ubuntu dengan menggunakan perintah berikut:

sudo apt-get install -y git jq unzip virtualenv

Anda kemudian dapat menginstal komponen penyebar dengan menggunakan perintah berikut:


wget https://raw.githubusercontent.com/Azure/sap-automation/main/deploy/scripts/configure_deployer.sh -O configure_deployer.sh
chmod +x ./configure_deployer.sh
./configure_deployer.sh

# Source the new variables

. /etc/profile.d/deploy_server.sh

Sampel

Folder ~/Azure_SAP_Automated_Deployment/samples berisi sekumpulan file konfigurasi sampel untuk mulai menguji kerangka kerja otomatisasi penyebaran. Anda dapat menyalinnya dengan menggunakan perintah berikut:

cd ~/Azure_SAP_Automated_Deployment

cp -Rp samples/Terraform/WORKSPACES ~/Azure_SAP_Automated_Deployment

Langkah selanjutnya