How to use Azure Managed Identity to access Azure Pubsub on ruby on rails?

111 views Asked by At

I am working on a Ruby on Rails (ROR) application. where we use Azure PubSub Service. To connect with Azure Pubsub, we use Primary Key (it's been fetched from Azure Key Vault).

Current setup/code used to connect to Azure PubSub Service

def get_auth_token
  now_seconds = Time.now.to_i
  payload = {
    aud: endpoint,
    exp: now_seconds + 60,
    iat: now_seconds,
  }.merge(payload.except(:aud, :exp, :iat))
  pubsub_key = VaultService.get_secret("AZURE-PUBSUB-KEY")
  JWT.encode(payload, pubsub_key, 'HS256')
end

def get_connection_url(hub)
  "wss://<pubsub-service>.webpubsub.azure.com/client/hubs/#{hub}?access_token=#{get_auth_token}"
end

Have gone through the PubSub documentation:-

  1. how-to-use-managed-identity-in-azure-pubsub states they officially support 4 programming languages (C#, Python, Java, Javascript), where they use AzureIdentity package to authenticate using MI (Managed Identity)

Instead of using Primary Key for authentication, we are looking to do it via Managed Identity, for our ROR applications. Could anyone please help/guide how the same can be achieved for ROR?

1

There are 1 answers

0
Vivek Vaibhav Shandilya On

Currently, it is not possible to use the Azure SDK for Ruby on Rails, as it has been deprecated.

For reference, check this document.

As of February 2021, the Azure Resource Management SDK for Ruby has entered a retirement phase and is no longer officially supported by Microsoft. Here is the complete list of packages that are affected by this. We are committed to making critical security and bug fixes for libraries in this repo until December 31, 2021. After that date, this repo will no longer be maintained.

For current users of the Azure Resource Management SDK for Ruby, we have prepared a migration guide that outlines different alternative approaches you can take moving forward. Please check the guide here.

If you have any questions, please feel free to open an issue on GitHub.