This page shows supported authentication methods and clients, and shows sample code you can use to connect Azure Queue Storage to other cloud services using Service Connector. You might still be able to connect to Azure Queue Storage in other programming languages without using Service Connector. This page also shows default environment variable names and values (or Spring Boot configuration) you get when you create the service connection.
Supported compute services
Service Connector can be used to connect the following compute services to Azure Queue Storage:
- Azure App Service
- Azure Container Apps
- Azure Functions
- Azure Kubernetes Service (AKS)
- Azure Spring Apps
Supported authentication types and client types
The table below shows which combinations of authentication methods and clients are supported for connecting your compute service to Azure Queue Storage using Service Connector. A “Yes” indicates that the combination is supported, while a “No” indicates that it is not supported.
Client type |
System-assigned managed identity |
User-assigned managed identity |
Secret / connection string |
Service principal |
.NET |
Yes |
Yes |
Yes |
Yes |
Java |
Yes |
Yes |
Yes |
Yes |
Java - Spring Boot |
Yes |
Yes |
Yes |
Yes |
Node.js |
Yes |
Yes |
Yes |
Yes |
Python |
Yes |
Yes |
Yes |
Yes |
This table indicates that all combinations of client types and authentication methods are supported, except for the Java - Spring Boot client type, which only supports the Secret / connection string method. All other client types can use any of the authentication methods to connect to Azure Queue Storage using Service Connector.
Default environment variable names or application properties and sample code
Use the connection details below to connect compute services to Queue Storage. For each example below, replace the placeholder texts
<account name>
, <account-key>
, <client-ID>
, <client-secret>
, <tenant-ID>
, and <storage-account-name>
with your own account name, account key, client ID, client secret, tenant ID and storage account name. For more information about naming conventions, check the Service Connector internals article.
System-assigned managed identity
SpringBoot client
Authenticating with a system-assigned managed identity is only available for Spring Cloud Azure version 4.0 or higher.
Default environment variable name |
Description |
Example value |
spring.cloud.azure.storage.queue.credential.managed-identity-enabled |
Whether to enable managed identity |
True |
spring.cloud.azure.storage.queue.account-name |
Name for the storage account |
storage-account-name |
spring.cloud.azure.storage.queue.endpoint |
Queue Storage endpoint |
https://<storage-account-name>.queue.core.windows.net/ |
Other clients
Default environment variable name |
Description |
Example value |
AZURE_STORAGEQUEUE_RESOURCEENDPOINT |
Queue storage endpoint |
https://<storage-account-name>.queue.core.windows.net/ |
Sample code
Refer to the steps and code below to connect to Azure Queue Storage using a system-assigned managed identity.
Install dependency.
dotnet add package Azure.Storage.Queues
dotnet add package Azure.Identity
Authenticate using Azure.Identity
and get the Azure Queue Storage endpoint from the environment variables added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
using Azure.Storage.Queues;
using Azure.Identity;
// Uncomment the following lines corresponding to the authentication type you want to use.
// system-assigned managed identity
// var credential = new DefaultAzureCredential();
// user-assigned managed identity
// var credential = new DefaultAzureCredential(
// new DefaultAzureCredentialOptions
// {
// ManagedIdentityClientId = Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_CLIENTID");
// });
// service principal
// var tenantId = Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_TENANTID");
// var clientId = Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_CLIENTID");
// var clientSecret = Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_CLIENTSECRET");
// var credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
Uri queueUri = new Uri(Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_RESOURCEENDPOINT"));
QueueClient queue = new QueueClient(queueUri, credential);
- Add the following dependencies in your pom.xml file:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-queue</artifactId>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.1.5</version>
</dependency>
- Authenticate using
azure-identity
and get the Azure Queue Storage endpoint from the environment variables added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
import com.azure.identity.*;
import com.azure.storage.queue.*;
import com.azure.storage.queue.models.*;
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-managed identity
// DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
// for user-assigned managed identity
// DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
// .managedIdentityClientId(System.getenv("AZURE_STORAGEQUEUE_CLIENTID"))
// .build();
// for service principal
// ClientSecretCredential credential = new ClientSecretCredentialBuilder()
// .clientId(System.getenv("AZURE_STORAGEQUEUE_CLIENTID"))
// .clientSecret(System.getenv("AZURE_STORAGEQUEUE_CLIENTSECRET"))
// .tenantId(System.getenv("AZURE_STORAGEQUEUE_TENANTID"))
// .build();
String endpoint = System.getenv("AZURE_STORAGEQUEUE_RESOURCEENDPOINT");
QueueClient queueClient = new QueueClientBuilder()
.endpoint(endpoint)
.queueName("<queueName>")
.credential(credential)
.buildClient();
- Install dependencies.
pip install azure-identity
pip install azure-storage-queue
- Authenticate using
azure-identity
and get the Azure Queue Storage endpoint from the environment variables added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
import os
from azure.identity import ManagedIdentityCredential, ClientSecretCredential
from azure.storage.queue import QueueServiceClient, QueueClient
# Uncomment the following lines corresponding to the authentication type you want to use.
# system-assigned managed identity
# cred = ManagedIdentityCredential()
# user-assigned managed identity
# managed_identity_client_id = os.getenv('AZURE_STORAGEQUEUE_CLIENTID')
# cred = ManagedIdentityCredential(client_id=managed_identity_client_id)
# service principal
# tenant_id = os.getenv('AZURE_STORAGEQUEUE_TENANTID')
# client_id = os.getenv('AZURE_STORAGEQUEUE_CLIENTID')
# client_secret = os.getenv('AZURE_STORAGEQUEUE_CLIENTSECRET')
# cred = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)
account_url = os.getenv('AZURE_STORAGEQUEUE_RESOURCEENDPOINT')
queue_client = QueueClient(account_url, queue_name='<queue_name>' ,credential=cred)
Install dependencies.
npm install @azure/identity
npm install @azure/storage-queue
Authenticate using @azure/identity
and get the Azure Queue Storage endpoint from the environment variables added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
const { QueueServiceClient } = require("@azure/storage-queue");
import { DefaultAzureCredential,ClientSecretCredential } from "@azure/identity";
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-assigned managed identity
// const credential = new DefaultAzureCredential();
// for user-assigned managed identity
// const clientId = process.env.AZURE_STORAGEQUEUE_CLIENTID;
// const credential = new DefaultAzureCredential({
// managedIdentityClientId: clientId
// });
// for service principal
// const tenantId = process.env.AZURE_STORAGEQUEUE_TENANTID;
// const clientId = process.env.AZURE_STORAGEQUEUE_CLIENTID;
// const clientSecret = process.env.AZURE_STORAGEQUEUE_CLIENTSECRET;
// const credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
const queueServiceClient = new QueueServiceClient(
process.env.AZURE_STORAGEQUEUE_RESOURCEENDPOINT,
credential
);
User-assigned managed identity
SpringBoot client
Authenticating with a user-assigned managed identity is only available for Spring Cloud Azure version 4.0 or higher.
Default environment variable name |
Description |
Example value |
spring.cloud.azure.storage.queue.credential.managed-identity-enabled |
Whether to enable managed identity |
True |
spring.cloud.azure.storage.queue.account-name |
Name for the storage account |
storage-account-name |
spring.cloud.azure.storage.queue.endpoint |
Queue Storage endpoint |
https://<storage-account-name>.queue.core.windows.net/ |
spring.cloud.azure.storage.queue.credential.client-id |
Client ID of the user-assigned managed identity |
00001111-aaaa-2222-bbbb-3333cccc4444 |
Other clients
Default environment variable name |
Description |
Example value |
AZURE_STORAGEQUEUE_RESOURCEENDPOINT |
Queue storage endpoint |
https://<storage-account-name>.queue.core.windows.net/ |
AZURE_STORAGEQUEUE_CLIENTID |
Your client ID |
<client-ID> |
Sample code
Refer to the steps and code below to connect to Azure Queue Storage using a user-assigned managed identity.
Install dependency.
dotnet add package Azure.Storage.Queues
dotnet add package Azure.Identity
Authenticate using Azure.Identity
and get the Azure Queue Storage endpoint from the environment variables added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
using Azure.Storage.Queues;
using Azure.Identity;
// Uncomment the following lines corresponding to the authentication type you want to use.
// system-assigned managed identity
// var credential = new DefaultAzureCredential();
// user-assigned managed identity
// var credential = new DefaultAzureCredential(
// new DefaultAzureCredentialOptions
// {
// ManagedIdentityClientId = Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_CLIENTID");
// });
// service principal
// var tenantId = Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_TENANTID");
// var clientId = Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_CLIENTID");
// var clientSecret = Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_CLIENTSECRET");
// var credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
Uri queueUri = new Uri(Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_RESOURCEENDPOINT"));
QueueClient queue = new QueueClient(queueUri, credential);
- Add the following dependencies in your pom.xml file:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-queue</artifactId>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.1.5</version>
</dependency>
- Authenticate using
azure-identity
and get the Azure Queue Storage endpoint from the environment variables added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
import com.azure.identity.*;
import com.azure.storage.queue.*;
import com.azure.storage.queue.models.*;
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-managed identity
// DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
// for user-assigned managed identity
// DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
// .managedIdentityClientId(System.getenv("AZURE_STORAGEQUEUE_CLIENTID"))
// .build();
// for service principal
// ClientSecretCredential credential = new ClientSecretCredentialBuilder()
// .clientId(System.getenv("AZURE_STORAGEQUEUE_CLIENTID"))
// .clientSecret(System.getenv("AZURE_STORAGEQUEUE_CLIENTSECRET"))
// .tenantId(System.getenv("AZURE_STORAGEQUEUE_TENANTID"))
// .build();
String endpoint = System.getenv("AZURE_STORAGEQUEUE_RESOURCEENDPOINT");
QueueClient queueClient = new QueueClientBuilder()
.endpoint(endpoint)
.queueName("<queueName>")
.credential(credential)
.buildClient();
- Install dependencies.
pip install azure-identity
pip install azure-storage-queue
- Authenticate using
azure-identity
and get the Azure Queue Storage endpoint from the environment variables added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
import os
from azure.identity import ManagedIdentityCredential, ClientSecretCredential
from azure.storage.queue import QueueServiceClient, QueueClient
# Uncomment the following lines corresponding to the authentication type you want to use.
# system-assigned managed identity
# cred = ManagedIdentityCredential()
# user-assigned managed identity
# managed_identity_client_id = os.getenv('AZURE_STORAGEQUEUE_CLIENTID')
# cred = ManagedIdentityCredential(client_id=managed_identity_client_id)
# service principal
# tenant_id = os.getenv('AZURE_STORAGEQUEUE_TENANTID')
# client_id = os.getenv('AZURE_STORAGEQUEUE_CLIENTID')
# client_secret = os.getenv('AZURE_STORAGEQUEUE_CLIENTSECRET')
# cred = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)
account_url = os.getenv('AZURE_STORAGEQUEUE_RESOURCEENDPOINT')
queue_client = QueueClient(account_url, queue_name='<queue_name>' ,credential=cred)
Install dependencies.
npm install @azure/identity
npm install @azure/storage-queue
Authenticate using @azure/identity
and get the Azure Queue Storage endpoint from the environment variables added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
const { QueueServiceClient } = require("@azure/storage-queue");
import { DefaultAzureCredential,ClientSecretCredential } from "@azure/identity";
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-assigned managed identity
// const credential = new DefaultAzureCredential();
// for user-assigned managed identity
// const clientId = process.env.AZURE_STORAGEQUEUE_CLIENTID;
// const credential = new DefaultAzureCredential({
// managedIdentityClientId: clientId
// });
// for service principal
// const tenantId = process.env.AZURE_STORAGEQUEUE_TENANTID;
// const clientId = process.env.AZURE_STORAGEQUEUE_CLIENTID;
// const clientSecret = process.env.AZURE_STORAGEQUEUE_CLIENTSECRET;
// const credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
const queueServiceClient = new QueueServiceClient(
process.env.AZURE_STORAGEQUEUE_RESOURCEENDPOINT,
credential
);
Connection string
Warning
Microsoft recommends that you use the most secure authentication flow available. The authentication flow described in this procedure requires a very high degree of trust in the application, and carries risks that are not present in other flows. You should only use this flow when other more secure flows, such as managed identities, aren't viable.
SpringBoot client
Application properties |
Description |
Example value |
spring.cloud.azure.storage.account |
Queue storage account name |
<storage-account-name> |
spring.cloud.azure.storage.access-key |
Queue storage account key |
<account-key> |
spring.cloud.azure.storage.queue.account-name |
Queue storage account name for Spring Cloud Azure version above 4.0 |
<storage-account-name> |
spring.cloud.azure.storage.queue.account-key |
Queue storage account key for Spring Cloud Azure version above 4.0 |
<account-key> |
spring.cloud.azure.storage.queue.endpoint |
Queue storage endpoint for Spring Cloud Azure version above 4.0 |
https://<storage-account-name>.queue.core.windows.net/ |
Other clients
Default environment variable name |
Description |
Example value |
AZURE_STORAGEQUEUE_CONNECTIONSTRING |
Queue storage connection string |
DefaultEndpointsProtocol=https;AccountName=<account-name>;AccountKey=<account-key>;EndpointSuffix=core.windows.net |
Sample code
Refer to the steps and code below to connect to Azure Queue Storage using a connection string.
Install dependency.
dotnet add package Azure.Storage.Queues
Get the connection string from the environment variable added by Service Connector.
using Azure.Storage.Queues;
var connectionString = Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_CONNECTIONSTRING");
QueueServiceClient service = new QueueServiceClient(connectionString);
- Add the following dependency in your pom.xml file:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-queue</artifactId>
</dependency>
- Get the connection string from the environment variable added by Service Connector.
String connectionString = System.getenv("AZURE_STORAGEQUEUE_CONNECTIONSTRING");
QueueClient client = new QueueClientBuilder()
.connectionString(connectionString)
.buildClient();
- Install dependency.
pip install azure-storage-queue
- Get the connection string from the environment variable added by Service Connector.
from azure.storage.queue import QueueServiceClient
connection_string = os.getenv('AZURE_STORAGEQUEUE_CONNECTIONSTRING')
queue_service = QueueServiceClient.from_connection_string(conn_str=connection_string)
Install dependency.
npm install @azure/storage-queue
Get the connection string from the environment variable added by Service Connector.
const { QueueServiceClient } = require("@azure/storage-queue");
const connection_string = process.env.AZURE_STORAGEQUEUE_CONNECTIONSTRING;
const queueServiceClient = QueueServiceClient.fromConnectionString(connection_string);
Service principal
SpringBoot client
Authenticating with a service principal is only available for Spring Cloud Azure version 4.0 or higher.
Default environment variable name |
Description |
Example value |
spring.cloud.azure.storage.queue.account-name |
Name for the storage account |
storage-account-name |
spring.cloud.azure.storage.queue.endpoint |
Queue Storage endpoint |
https://<storage-account-name>.queue.core.windows.net/ |
spring.cloud.azure.storage.queue.credential.client-id |
Client ID of the service principal |
00001111-aaaa-2222-bbbb-3333cccc4444 |
spring.cloud.azure.storage.queue.credential.client-secret |
Client secret to perform service principal authentication |
Aa1Bb~2Cc3.-Dd4Ee5Ff6Gg7Hh8Ii9_Jj0Kk1Ll2 |
Other clients
Default environment variable name |
Description |
Example value |
AZURE_STORAGEQUEUE_RESOURCEENDPOINT |
Queue storage endpoint |
https://<storage-account-name>.queue.core.windows.net/ |
AZURE_STORAGEQUEUE_CLIENTID |
Your client ID |
<client-ID> |
AZURE_STORAGEQUEUE_CLIENTSECRET |
Your client secret |
<client-secret> |
AZURE_STORAGEQUEUE_TENANTID |
Your tenant ID |
<tenant-ID> |
Sample code
Refer to the steps and code below to connect to Azure Queue Storage using a service principal.
Install dependency.
dotnet add package Azure.Storage.Queues
dotnet add package Azure.Identity
Authenticate using Azure.Identity
and get the Azure Queue Storage endpoint from the environment variables added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
using Azure.Storage.Queues;
using Azure.Identity;
// Uncomment the following lines corresponding to the authentication type you want to use.
// system-assigned managed identity
// var credential = new DefaultAzureCredential();
// user-assigned managed identity
// var credential = new DefaultAzureCredential(
// new DefaultAzureCredentialOptions
// {
// ManagedIdentityClientId = Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_CLIENTID");
// });
// service principal
// var tenantId = Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_TENANTID");
// var clientId = Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_CLIENTID");
// var clientSecret = Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_CLIENTSECRET");
// var credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
Uri queueUri = new Uri(Environment.GetEnvironmentVariable("AZURE_STORAGEQUEUE_RESOURCEENDPOINT"));
QueueClient queue = new QueueClient(queueUri, credential);
- Add the following dependencies in your pom.xml file:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-queue</artifactId>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.1.5</version>
</dependency>
- Authenticate using
azure-identity
and get the Azure Queue Storage endpoint from the environment variables added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
import com.azure.identity.*;
import com.azure.storage.queue.*;
import com.azure.storage.queue.models.*;
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-managed identity
// DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
// for user-assigned managed identity
// DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
// .managedIdentityClientId(System.getenv("AZURE_STORAGEQUEUE_CLIENTID"))
// .build();
// for service principal
// ClientSecretCredential credential = new ClientSecretCredentialBuilder()
// .clientId(System.getenv("AZURE_STORAGEQUEUE_CLIENTID"))
// .clientSecret(System.getenv("AZURE_STORAGEQUEUE_CLIENTSECRET"))
// .tenantId(System.getenv("AZURE_STORAGEQUEUE_TENANTID"))
// .build();
String endpoint = System.getenv("AZURE_STORAGEQUEUE_RESOURCEENDPOINT");
QueueClient queueClient = new QueueClientBuilder()
.endpoint(endpoint)
.queueName("<queueName>")
.credential(credential)
.buildClient();
- Install dependencies.
pip install azure-identity
pip install azure-storage-queue
- Authenticate using
azure-identity
and get the Azure Queue Storage endpoint from the environment variables added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
import os
from azure.identity import ManagedIdentityCredential, ClientSecretCredential
from azure.storage.queue import QueueServiceClient, QueueClient
# Uncomment the following lines corresponding to the authentication type you want to use.
# system-assigned managed identity
# cred = ManagedIdentityCredential()
# user-assigned managed identity
# managed_identity_client_id = os.getenv('AZURE_STORAGEQUEUE_CLIENTID')
# cred = ManagedIdentityCredential(client_id=managed_identity_client_id)
# service principal
# tenant_id = os.getenv('AZURE_STORAGEQUEUE_TENANTID')
# client_id = os.getenv('AZURE_STORAGEQUEUE_CLIENTID')
# client_secret = os.getenv('AZURE_STORAGEQUEUE_CLIENTSECRET')
# cred = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)
account_url = os.getenv('AZURE_STORAGEQUEUE_RESOURCEENDPOINT')
queue_client = QueueClient(account_url, queue_name='<queue_name>' ,credential=cred)
Install dependencies.
npm install @azure/identity
npm install @azure/storage-queue
Authenticate using @azure/identity
and get the Azure Queue Storage endpoint from the environment variables added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
const { QueueServiceClient } = require("@azure/storage-queue");
import { DefaultAzureCredential,ClientSecretCredential } from "@azure/identity";
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-assigned managed identity
// const credential = new DefaultAzureCredential();
// for user-assigned managed identity
// const clientId = process.env.AZURE_STORAGEQUEUE_CLIENTID;
// const credential = new DefaultAzureCredential({
// managedIdentityClientId: clientId
// });
// for service principal
// const tenantId = process.env.AZURE_STORAGEQUEUE_TENANTID;
// const clientId = process.env.AZURE_STORAGEQUEUE_CLIENTID;
// const clientSecret = process.env.AZURE_STORAGEQUEUE_CLIENTSECRET;
// const credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
const queueServiceClient = new QueueServiceClient(
process.env.AZURE_STORAGEQUEUE_RESOURCEENDPOINT,
credential
);
Next steps
Follow the tutorials listed below to learn more about Service Connector.