this coin must have been minted during Safavids, Safi I (AH 1038-1052/1629-1642 AD) rule. Was Shamakhi under Persian rule?
It's a good question Maythem

Shamakhi was under safavid rule since Ismaïl Shah I and became under Tahmasp Shah I, a persian province with a safavid governor at its head.
from 1034 to 1043 AH, the Governor of this Shirvan Province was a safavid military commander named Qazak Khan Cherkes.
This coin could well have been struck at this time.
Later, between 1136 & 1155 AH, the city fell in russian hands after the Russia-Persia war; Nadir Shah will re-annexed it and Shirvan became a semi-independant khanate.