On June 15, 2021 Turkey and Azerbaijan signed a "protocol of alliance" in the historic city of Shusha, the scene of heavy fighting in the recent war between Azerbaijan and Armenia. The protocol contained many clauses that could appear threatening to Russia. There were clauses on collective security and military cooperation:
"In the event of their independence, the sovereignty of internationally recognized borders, territorial integrity, inviolability or security by a third State or States, the parties shall conduct joint consultations to eliminate the threat or to prevent aggression. 
"The parties will encourage the exchange of personnel aimed at strengthening the defense capability and military security, conducting joint exercises and trainings, increasing the interaction capabilities of the armed forces of the two countries, cooperating closely in the management of weapons and ammunition on the basis of modern technologies, and ensuring coordinated activities of authorized agencies and institutions for this purpose."
Other clauses spoke of cooperation in the supply of gas to Europe that could compete with Russian efforts and emphasizing Turkey's role in regulating the situation in areas formerly controlled by Armenia, where Russia has a peacekeeping force:
"The parties emphasize the advanced role of Turkey and Azerbaijan in the implementation of the strategic Southern Gas Corridor, which contributes to the energy security of the region and Europe and ensures the diversification of sources and routes of natural gas."
"The special geographical location of the Nakhchivan Autonomous Republic of the Republic of Azerbaijan will be taken into account. The sides emphasize that the contribution made by Turkey to the operation of the Turkish-Russian Joint Center in the territories of Azerbaijan liberated from occupation plays an important role in ensuring peace, stability and prosperity of the region."
Viktor Zavarzin, Deputy Chairman of the State Duma Defense Committee, claimed that the agreement left open the possibility of a Turkish military base in Azerbaijan that would be tantamount to an enlargement of NATO. Zavarzin believed such a base was in the offing. “Considering the circumstances Russia should scrutinize the situation, keep monitoring the issue and be ready to react", advised the deputy.
In contrast, Aleksander Artamonov, a political scientist and military expert advised Russia to remain calm in an article titled " From Kars to Shusha... and Back." Nothing had changed in the military relations between Baku and Ankara and the protocol merely codified the existing situation. The agreement left out mention of a Turkish base to the disgruntlement of the pro-Turkish faction in Azerbaijan, and Azerbaijan had kept its distance from Turkish policy, for example, during the recent fighting in Gaza.
The centenary of the 1921 treaty of Kars was recently observed. In that treaty, the Soviet Union and Turkey together with the republics in the Caucasus agreed on borders and the Soviet Union and Turkey agreed to guarantee them. This prevented Turkey from actively siding with the Entente against the Soviet Union. The parallel is clear: if Russia wants to avoid a NATO presence on its southern border, it must establish a partnership with Turkey and simultaneously upgrade its influence in Azerbaijan..
Artamanov's article follows below: 
Turkey's President Recep Tayip Erdogan and Azerbaijan's President Ilham Aliev following the signing of the Shusha Protocol
"On October 13, 1921 the young republics of Transcaucasia (where the Bolsheviks came to power) and Turkey (where the Kemalists won [the War of Independence]) signed the Treaty of Kars.
"Soviet Russia was involved in the signing of the treaty in its capacity of geopolitical center (which the Bolsheviks of Transcaucasia focused on), and as the guarantor of the treaty's basic provision - the establishment of the southern border between the three republics [the author means Armenia, Azerbaijan and Georgia, of which Transcaucasia was comprised] and Turkey. This border soon became the southern border of the Soviet Union.
"A hundred years later, in another milestone, the Azerbaijani-Turkish declaration of alliance was pompously signed in the key Karabakh city of Shusha, situated on the southern outskirts of Russia. The two diplomatic events are linked not only by the symbolism of the centuries-old border. The document, which deals with the relations between the two countries, makes a direct reference to the Kars Treaty. The latter, let’s note, involved five parties. But before we follow the geopolitical connection in time between Shusha and Kars, let’s cross the t’s regarding the regional balance of power during the last century. Let’s scrutinize the basic idea of the Shusha Statement (not to be confused with the Shushenskoye settlement in Siberia).
"Despite all significance given to the signing of the document, basically it only reaffirms the existing level of bilateral relations, which was achieved in recent years. Azerbaijani-Turkish relations have been practically a military-political alliance for some time.
"And while the high development of partnership in the political realm between the two countries never aroused doubt, the military element has grown amidst last year’s war in Karabakh. Turkey's role in Karabakh consisted of [providing] crucial military and technical support to the Azerbaijani army in Karabakh and discharging the function of guarantor to prevent third country-intervention in the Armenian-Azerbaijani conflict. The declaration adopted in Shusha officially solemnizes the new post-conflict reality.
"If previously, Ankara made only verbal commitments to protect Baku, which were personified in Erdogan’s course, the current treaty Turkey’s obligations are solemnized in writing. Actually by this treaty Baku is guaranteed to receive Turkey’s support in case of an emergency regional situation with an eye to the post-Erdogan era.
"However, analyzing the Azerbaijani social networks, the pro-Turkish segment [of Azerbaijani Internet users] is clearly disappointed. The main reason is that the document makes no mention of a Turkish base in Azerbaijan. The Baku radicals see this base as an important element in a future Turko-centric integration. Moreover, the Shusha Declaration About Alliance with Ankara doesn’t compensate for the presence of a Russian peacekeeping contingent in Karabakh in the country's internationally recognized territory.
"The absence of Devlet Bahceli the main Turkish supporter of the “Great Turan” idea, the leader of the Nationalist Movement Party, and Erdogan’s partner in the ruling coalition, Devlet Bahceli at the ceremony in Shusha was also most symbolic. Before this incident Bahceli posted an offended tweet about Baku’s cool reception of his party’s project to build a Turkish school in Shusha. Baku’s official excuse for the rejection of the project was “the inconsistency the project design with the characteristic architectural design in Shusha.” Seemingly, a full-fledged Turkish base would also be inconsistent with the design of Azerbaijani sovereignty.
Devlet Bahceli (Source: Hurriyet.com.tr)
"On the other hand, Azerbaijan's support for Turkey may in fact be only symbolic in nature. Baku doesn’t prioritize the main directions of possible threats to Turkey. Azerbaijan has no interest in the Syrian conflict while its silence during the latest escalation of the Gaza conflict was altogether at odds with Erdogan’s hyperactive position on the issue. Turkey's objectives in the Eastern Mediterranean is likely to compete with Azerbaijan’s energy plans to supply its own gas to European markets. The only sphere, in which the alliance with Ankara could put Azerbaijan into a “geopolitical Zugzwang” [where it is forced to make a bad move] is Turkey’s policy towards Crimea.
"Turkey believes the peninsula (on which it has its own designs) to be Ukrainian. Therefore, Erdogan is one of the active supporters of the 'Crimean platform.' But this is an issue of mutual accommodation by Baku and Moscow over the 'red lines' of national security.
"Thus, in terms of security, Baku managed to obtain Turkey’s guarantee for its gains from the Karabakh conflict while at the same time not conceding its sovereignty, allowing Baku to distance itself from the prospect of being drawn into Ankara’s revisionist projects. This is undoubtedly a success of Ilham Aliyev’s diplomacy.
"In turn Erdogan, understanding the limitations of the military and political power of the Azerbaijani alliance, talked in Shusha about the economy. This is quite understandable, because the time for to renewing the rates for Azerbaijani gas is around the corner, and Ankara obviously expects an “ally's discount” on top of the preexisting “fraternal” one.
"Erdogan’s emphasis on Russia’s role [in the region] may have come as a surprise, especially coming during his triumphant visit to Karabakh. “We want to make the region prosperous. We, together with President Aliyev and Russian President Vladimir Putin, have the corresponding determination to do so,” said the Turkish leader, commenting on the adopted declaration.
"This is the fitting moment to return to the analogy with the Treaty of Kars. Let’s recall that the treaty served as a confirmation given by the Transcaucasian republics to the Moscow Treaty between Russia and Turkey. A century ago, the main achievement of the young Soviet diplomacy was to anchor the southern borders of Russian geopolitical influence. In return, Turkey served as a guarantor of Nakhchivan Republic’s existence within Azerbaijan. Thus, Moscow managed to neutralize Turkey as a potentially hostile country, which could serve as a conduit for the hostile Entente policy towards Moscow.
"Today’s goals of Russian diplomacy within the new conditions in the South Caucasus recalls those of a century ago. The trilateral agreements on Karabakh signed under the Kremlin’s mediation return the region to the century-old borders of the Soviet republics established by Moscow following the collapse of the Russian Empire. Turkey, as it did a century ago, acts as a guarantor of Azerbaijani territories (however this time in Karabakh).
"Russia’s cooperation with Turkey in Karabakh is an important element, which allows neutralizing Ankara as a lever for potentially dangerous NATO ambitions in the South Caucasus. While Russia is an ally of Armenia, it also has a military presence in Azerbaijan. However, the status of such a presence is not yet clearly defined.
"The unclarity in the military-political element of relations with Baku and a the absence of clear articulation by Moscow of its vision for the region's future as the leading power in the South Caucasus, is the main issue preventing the completion of the current geopolitical layout according to the Kars design. For the Shusha declaration to become a piece of the puzzle in the “Kars-2” picture, Moscow needs, at least, to develop its relations with Azerbaijan to the level of Baku’s relations with Ankara.
"In the rapidly changing global geopolitical landscape, this task becomes important in terms of both consolidating Russian influence in Baku and regulating the region in cooperation with Turkey, rather than competition with NATO in dangerous proximity to Russia's southern borders)."
Aleksander Artamanov (Source: Eadaily.com)