Many foreign troops visited Yasukuni Shrine

The country whose military has the most frequency visited Yasukuni formally is the USA, the second is Germany.
Especially the military attaches of the German Embassy in Japan always visit there both upon arriving in and just before leaving Japan.

Until some time ago, Japanese ministers used to visit Yasukuni shrine as a matter of course. It, however, slipped into a troublesome political issue insidiously. I think main players in complicating the situation would be left-wing powers which came into the postwar Japan and have worked behind the scenes. They always have emitted smoke without fire, spoiled relations between Japan and the rest of the East Asian countries.
Normally, it would make no sense for differing with other country’s way of enshrining its war dead. Even the US army that was engaged in mortal combat with Japan in the past war has viseted Yasukuni many times, and of course successive Japanese PMs also have visited Arlington Cemetery.
.

. . . .* Militaries that have ever visited Yasukuni*

Commander Ricardo Laure and the 51 crew of the Juan Sebastián Elcano,training squadron of the Spanish navy

Commander Ricardo Laure of the Juan Sebastián Elcano, training squadron of the Spanish navy, and his 50 crew members

.

General Lieutenant Johanes Steinhoff of Luftwaffe

General Lieutenant Johanes Steinhoff of Luftwaffe

.

Rear Admiral Daniel.T.Smith, Captain general of the US Army in Japan, and 25 top officials

Rear Admiral Daniel.T.Smith, Captain general of the US Army in Japan, and 25 top officials

.

Crew members and cadets of the french escort ship Victor Cherchez and the aircraft carrier Jeanne d'Arc

Crew members and cadets of the French escort ship Victor Cherchez and the aircraft carrier Jeanne d’Arc

.

Cadets of Army-Navy-Air Force of Italy

Cadets of Army-Navy-Air Force of Italy

.

Ambassadors to Japan, Colonel Sylva and cadets of the Emeraldas, training squadron of the Chilean navy

Colonel Sylva and cadets of the Emeraldas, training squadron of the Chilean navy, and Ambassador of Chile to Japan

.

Military attaches of Brazil,Israel, Pohland and Turkey

Military attaches of Brazil,Israel, Poland and Turkey

.

Captain Luis and his 60 men of training squadron of Peru

Captain Luis and his 60 men of training squadron of Peru

.

Cadets of the United States Air Force Academy

Cadets of the United States Air Force Academy

.

Minister of Defense Andreotti and the cadets of Army-Navy-Air Force of Italy

Minister of Defense Andreotti and cadets of Army-Navy-Air Force of Italy

.

Major of Marines Oscarmás, Captain of the Libertad, training squadron of the Argentina navy, and navy cadets.

Cadets and Lieutenant commander Oscarmás of Commanding officer of the Libertad, training squadron of the Argentina navy

.

Major of marines ,a commander of training squadron of Thailand

Major of marines Bantom, a commander of training squadron of Thailand

.

Captain of the Custódio de Melo,training squadron of Brazil, cadets and 120 crew

Captain of the Custódio de Melo, s training squadron of Brazil, cadets and 120 crew members