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:-
- 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?
Currently, it is not possible to use the Azure SDK for Ruby on Rails, as it has been deprecated.
For reference, check this document.
If you have any questions, please feel free to open an issue on GitHub.