Azure

Azure仮想マシンのUbuntuでapt updateを行うとtrusted.gpgでエラーがでる

はじめに

Azure仮想マシンでUbuntuを立てたとき下記のようなエラーが発生したので調査してみました。

root@vm2:~# apt update
Hit:1 http://azure.archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://azure.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://azure.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:4 http://azure.archive.ubuntu.com/ubuntu jammy-security InRelease
Hit:5 https://packages.microsoft.com/ubuntu/22.04/prod jammy InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
W: https://packages.microsoft.com/ubuntu/22.04/prod/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.

 

どんな時にエラーが発生したのかというと /etc/apt/sources.list.d/microsoft-prod.list が登録されているのが問題ようです。

/etc/apt/trusted.gpg が参照されています。

対処

これを対処する方法はファイルを移動してあげます。

root@vm2:~# apt update
Hit:1 http://azure.archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://azure.archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB]
Get:3 http://azure.archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB]
Get:4 http://azure.archive.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Fetched 324 kB in 1s (484 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.

移動後はアップデートできていることがわかります。

 

必要な場合は下記の方法でインストールします。

.NET と Ubuntu の概要 - .NET | Microsoft Learn
.NET と Ubuntu の概要 - .NET | Microsoft Learn

Ubuntu に .NET SDK と .NET ランタイムをインストールするさまざまな方法を示します。

learn.microsoft.com

まとめ

同じイメージを利用しているのにどうしてこのようになったかは不明です。イメージに差分があるとは思いませんがインストールされているものが異なりました。

Microsoft Defender for Cloud が絡んでいるような気がしますが、ひょっとしたらインスタンスガチャかもしれません。

どちらにせよ確認する方法はログを追っかけるなど必要があります。

-Azure
-