Michal_F use the following to create a profile file in your cloud shell and then you can use get-ip whenever you like
I had to calculate and create the directory and file name via the script for some reason. If I grabbed the values and manually created the file/directory they were not picked up by PowerShell when I logged in.
I used get-ip to fit in with the standard verb-noun naming convention
#see https://docs.microsoft.com/en-us/azure/cloud-shell/quickstart-powershell?msclkid=5ba858d7cf8711ecb6f4442678f692c6#use-custom-profile
#Create the directory to contain the profile file
md (split-path $profile.CurrentUserAllHosts)
#Create function to grab the ip
"function get-ip {curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'}" | out-file (split-path $profile.currentuserallhosts -leaf)
#Now restart cloudshell