このガイドは、Azure Migrate アプリケーションと Java バージョン 7 (AppCAT) ツールのコード評価用のカスタム YAML ベースのルールを作成するエンジニア、コンサルタント、その他のユーザーを対象にしています。
概要については、「 Azure Migrate Application and Code Assessment for Java の概要 」を参照してください。詳細については、 AppCAT 7 の CLI コマンド ガイドを参照してください。
AppCAT には、移行を計画しているアプリケーションで使用される API、テクノロジ、アーキテクチャを分析するルールベースの移行ツールが含まれています。 実際、AppCAT 分析プロセスは AppCAT 規則を使用して実装されます。 AppCAT では、アーカイブからのファイルの抽出、ファイルの逆コンパイル、ファイルの種類のスキャンと分類、XML やその他のファイル コンテンツの分析、アプリケーション コードの分析、レポートの作成に内部的にルールを使用します。
ルールの使い方を始める
AppCAT ルールセット プロジェクトは、静的コード分析に役立つ将来のルールを提供します。 また、このプロジェクトは、より豊富なルールセットの作成を支援するために、主題の専門家が共有する問題にも貢献しています。
基本的なルール形式は、アップストリームの konveyor ルールセットから取得されます。 続行する前に、ルール メタデータに関するドキュメントを必ず確認してください。
AppCAT のその他のルール メタデータ
AppCAT には konveyor ルールセットで説明されている規則メタデータが組み込まれていますが、次の一覧で説明するように、レポートをより階層化するためのルールに関する詳細情報が提供されます。
- AppCAT では、ルールに次の 3 つのドメインが追加されます。
- Azure の準備: 目標は、Azure リソースとシームレスに連携するようにアプリケーション リソースを Azure に移行することです。
- クラウド ネイティブ: 目標は、クラウドに優しい原則に従ってアプリケーションを最適化することです
- Java の最新化: 目標は、サポートされている Java バージョンと最新の API を採用することでアプリケーションを最適化し、非推奨の機能によるセキュリティ リスクを回避することです。
- AppCAT によってルール カテゴリが追加されます。 必要に応じて、異なるルールをカテゴリにグループ化できます。たとえば、 見つかった MySQL/PostgreSQL データベースは両方とも データベース移行に属している可能性があります。
ドメイン/カテゴリメタデータは、カスタムルールの label
プロパティの下に書き込まれます。 次の例に示すように、AppCAT レポートには、このようなラベルを持つルールのみが表示されます。
labels:
- ___domain=azure-readiness
- category=database-migration
ルールの作成
次の規則の例では、MySQL データベースがプロジェクト内に見つかるかどうかを識別します。 データベースが見つかった場合は、Azure Database for MySQL に移行することをお勧めします。
- category: potential
customVariables: []
description: MySQL database found
effort: 3
labels:
- konveyor.io/target=azure-aks
- konveyor.io/source
- ___domain=azure-readiness
- category=database-migration
links:
- title: Azure Database for MySQL documentation
url: https://learn.microsoft.com/azure/mysql
message: |-
To migrate a Java application that uses a MySQL database to Azure, you can follow these recommendations:
* Use a managed **Azure Database for MySQL**: For that create a managed MySQL database in Azure and choose the appropriate pricing tier based on your application's requirements for performance, storage, and availability.
* **Migrate** the existing MySQL database: For that you can use the Azure Database Migration Service (DMS) to perform an online migration with minimal downtime.
* Update the application's **database connection** details: Modify the Java application's configuration to point to the newly provisioned Azure Database for MySQL. Update the connection string, hostname, port, username, and password information accordingly.
* Enable **monitoring and diagnostics**: Utilize Azure Monitor to gain insights into the performance and health of your Java application and the underlying MySQL database. Set up metrics, alerts, and log analytics to proactively identify and resolve issues.
* Implement **security** measures: Apply security best practices to protect your Java application and the MySQL database. This includes implementing authentication and authorization mechanisms with passwordless connections and leveraging Microsoft Defender for Cloud for threat detection and vulnerability assessments.
* **Backup** your data: Azure Database for MySQL provides automated backups by default. You can configure the retention period for backups based on your requirements. You can also enable geo-redundant backups, if needed, to enhance data durability and availability.
ruleID: azure-database-mysql-01000
when:
and:
- or:
- java.dependency:
lowerbound: 0.0.0
nameregex: ([a-zA-Z0-9._-]*)mysql([a-zA-Z0-9._-]*)
- builtin.filecontent:
filePattern: build\.gradle$
pattern: mysql
- builtin.file:
pattern: ^([a-zA-Z0-9._-]*)mysql-connector([a-zA-Z0-9._-]*)\.jar$
- builtin.filecontent:
filePattern: (/|\\)([a-zA-Z0-9._-]+)\.(xml|properties|yaml|yml)$
pattern: (?i)jdbc:mysql
- builtin.filecontent:
filePattern: (/|\\)([a-zA-Z0-9._-]+)\.(xml|properties|yaml|yml)$
pattern: (?i)r2dbc:mysql
- builtin.filecontent:
filePattern: (/|\\)([a-zA-Z0-9._-]+)\.(xml|properties|yaml|yml)$
pattern: (?i)r2dbc:pool:mysql
- not: true
or:
- builtin.filecontent:
filePattern: (/|\\)(application|bootstrap)(-[a-zA-Z0-9]+)*?\.(properties|yaml|yml)$
pattern: ([a-zA-Z0-9-]+)\.mysql\.database\.azure\.com$
- java.dependency:
lowerbound: 0.0.0
nameregex: ([a-zA-Z0-9._-]*)spring-cloud-azure-starter-jdbc-mysql([a-zA-Z0-9._-]*)
ルールを実行する
AppCAT CLI でルールを実行する場合は、次の例に示すように、規則のみを実行するか、AppCAT の既定の規則セットを使用してルールを一緒に実行するかを選択できます。
# run appcat rules with default ruleset, it means run your rules with appcat provided rules toger
appcat analyze \
--input <input> \
--output <output> \
--target <target> \
--rules custom-rule1.yaml,custom-rule2.yaml
# only run your own rules
appcat analyze \
--input <input> \
--output <output> \
--target <target> \
--rules custom-rule1.yaml,custom-rule2.yaml \
--enable-default-rulesets=false