The error "Operation returned an invalid status code 'Unauthorized'" when registering a server endpoint and installing the agent usually indicates that the request to Azure is failing due to authentication or permission issues.

Yasar Shaikh 140 Reputation points
2025-05-27T06:08:34.4366667+00:00

The error "Operation returned an invalid status code 'Unauthorized'" when registering a server endpoint and installing the agent usually indicates that the request to Azure is failing due to authentication or permission issues.

NOTE -I have de-registered this server (an Azure File Sync agent) from one Storage Sync Service and re-register it with a new one (which can be connected to a different storage account and file share).

Performed Trouble shooting

I have owner access

The Azure File Sync agent is compatible with the OS ( Win2016) version.

Reinstalled agent

Please help.

Azure Storage
Azure Storage
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,529 questions
{count} votes

Accepted answer
  1. Alex Burlachenko 9,780 Reputation points
    2025-05-27T07:43:54.4133333+00:00

    Hi Yasar Shaikh,

    thanks so much for posting that on the q&a, appreciate you taking the time to set out all the details.

    even if u do have owner access at subscription level, the sync service could still throw out this error if the managed identity lacks proper permissions.

    be sure that the managed identity of the storage sync service has "contributor" or "storage file data smb share contributor" role on the storage account that you're syncing to. owner rights sometimes don't propagate down correctly, so this is not uncommon. here's the ms doc on azure file sync roles: assign access permissions.

    next, make sure the server's registration has not hung in a strange half-state. try running unregister-azstoragesyncserver in powershell (admin mode!!!) to clean out the remnants, then register again. often the previous registration haunts u even after you're convinced it's gone. further reading here: unregister server.

    in addition to that, when u reinstalled the agent, please ensure u used the latest release from the microsoft download center. outdated agents will freak out with newer apis. download it fresh here: download azure file sync agent.

    lastly if u've switched to a different storage account, check that the new one has network rules to accept traffic from the sync service. "unauthorized" errors are a favorite of misconfigs even if perms are set correctly. look at the "networking" tab of the storage account in the azure portal and see if it's not blocking u. Set up the network rules and virtual networks.

    hope that helps! if you’re still stuck, send me the exact powershell error log (the -debug output is pure gold), and I’ll investigate deeper.

    good luck ))
    Alex
    P.S. If my answer help to you, please Accept my answer
    PPS That is my Answer and not a Comment
    https://ctrlaltdel.blog/
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.