Azure VM creation using SSH_key


I followed this link: Terraform Registry
I’m spinning up VM on Azure and using ssh_keys option.
When I try logging into server, I’m getting error as “Permission denied (publickey)”. How can we set right permission to public key while uploading to server?

Is there a way to use “use existing key stored in Azure” option wherein we pass the kay name stored in Azure?
Sample code:

#Create virtual machine azurerm_virtual_machine azurerm_linux_virtual_machine
resource “azurerm_virtual_machine” “myterraformvm” {
name = var.vm_name #“myVM”
location = var.region
resource_group_name = var.resource_group_name
network_interface_ids = []
vm_size = var.vm_size #“Standard_DS1_v2”

storage_image_reference {
publisher = var.vm_publisher
offer = var.vm_offer #UbuntuServer, WindowsServer
sku = var.vm_sku
version = var.vm_version

storage_os_disk {
name = “${var.vm_name}_OSDisk_1_c7bfd79ffd5d4273a08883ce9bb016a9”
caching = “ReadWrite”
create_option = “FromImage”
managed_disk_type = var.os_disk_type

#Delete OS Disk on VM termination
delete_os_disk_on_termination = var.terminate_disk

os_profile {
computer_name = var.vm_name
admin_username = var.admin_username


os_profile_linux_config {
disable_password_authentication = true
ssh_keys {
key_data = file("/opt/stackstorm/keys/Test.ppk")
path = “/home/azureuser/.ssh/authorized_keys”