[verb (dict form)] + にあたって / にあたり [noun] + にあたって / にあたり
The grammar pattern にあたって (or its more formal variant にあたり) is used to express "on the occasion of," "when," or "at the time of." It marks an important event, occasion, or turning point, and introduces an action, decision, or statement that is made in connection with that occasion.
This pattern carries a formal and significant tone, so it is used for noteworthy events – not everyday actions. You would use it for things like starting a new job, launching a project, giving a speech, or undertaking something important.
にあたって attaches to nouns or the plain (dictionary) form of verbs:
Both forms are largely interchangeable. にあたり tends to appear more often in written or highly formal speech (e.g., official documents, speeches), while にあたって is slightly more common in general formal contexts. In practice, the difference is minimal.