Convert Figma logo to code with AI

Azure logoazure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.

2,297
1,956
2,297
931

Top Related Projects

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.

This repository is for active development of the Azure SDK for Go. For consumers of the SDK we recommend visiting our public developer docs at:

The official AWS SDK for Java 1.x. The AWS SDK for Java 2.x is available here: https://github.com/aws/aws-sdk-java-v2/

Quick Overview

The Azure/azure-sdk-for-java repository contains the official Azure SDK for Java, providing developers with libraries to interact with various Azure services. It offers a consistent and idiomatic Java API for Azure, enabling developers to easily integrate Azure services into their Java applications.

Pros

  • Comprehensive coverage of Azure services
  • Consistent API design across different Azure services
  • Regular updates and maintenance by Microsoft
  • Extensive documentation and code samples

Cons

  • Large repository size, which may lead to longer clone times
  • Learning curve for developers new to Azure
  • Potential version compatibility issues between different Azure service libraries
  • Some services may have limited functionality compared to their REST API counterparts

Code Examples

  1. Authenticating with Azure:
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();

This code creates a default credential object for authenticating with Azure services.

  1. Creating a Storage Blob client:
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
    .endpoint("https://<storage-account-name>.blob.core.windows.net")
    .credential(credential)
    .buildClient();

This example demonstrates how to create a Blob Service client for interacting with Azure Blob Storage.

  1. Sending a message to an Azure Service Bus queue:
ServiceBusClientBuilder builder = new ServiceBusClientBuilder()
    .connectionString("<service-bus-connection-string>");
ServiceBusSenderClient sender = builder.sender()
    .queueName("<queue-name>")
    .buildClient();

sender.sendMessage(new ServiceBusMessage("Hello, Azure!"));

This code shows how to send a message to an Azure Service Bus queue using the SDK.

Getting Started

To start using the Azure SDK for Java:

  1. Add the required dependencies to your project's pom.xml file:
<dependency>
  <groupId>com.azure</groupId>
  <artifactId>azure-core</artifactId>
  <version>1.36.0</version>
</dependency>
<dependency>
  <groupId>com.azure</groupId>
  <artifactId>azure-identity</artifactId>
  <version>1.8.1</version>
</dependency>
  1. Import the necessary classes in your Java code:
import com.azure.core.credential.TokenCredential;
import com.azure.identity.DefaultAzureCredentialBuilder;
  1. Create a credential object and use it to initialize Azure service clients:
TokenCredential credential = new DefaultAzureCredentialBuilder().build();
// Use the credential to create service clients

For more detailed instructions and service-specific examples, refer to the official Azure SDK for Java documentation.

Competitor Comparisons

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.

Pros of azure-sdk-for-python

  • More concise and readable syntax, typical of Python
  • Faster development time due to Python's simplicity
  • Better integration with data science and AI libraries

Cons of azure-sdk-for-python

  • Generally slower execution compared to Java
  • Less strict typing, which can lead to runtime errors
  • Fewer enterprise-level features out of the box

Code Comparison

azure-sdk-for-python:

from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient

credential = DefaultAzureCredential()
blob_service = BlobServiceClient(account_url, credential=credential)

azure-sdk-for-java:

DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
    .endpoint(accountUrl)
    .credential(credential)
    .buildClient();

The Python code is more concise and straightforward, while the Java code offers more explicit object creation and configuration. Both SDKs provide similar functionality, but the syntax and structure reflect the characteristics of their respective languages.

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.

Pros of azure-sdk-for-js

  • Easier integration with Node.js and browser-based applications
  • Supports TypeScript, providing better type safety and developer experience
  • Generally smaller package sizes, beneficial for web applications

Cons of azure-sdk-for-js

  • May have less comprehensive coverage of Azure services compared to Java SDK
  • Performance might be slightly lower for computationally intensive tasks
  • Asynchronous nature can be challenging for developers used to synchronous code

Code Comparison

azure-sdk-for-js:

import { BlobServiceClient } from "@azure/storage-blob";

const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString);
const containerClient = blobServiceClient.getContainerClient(containerName);
await containerClient.uploadBlockBlob(blobName, data, data.length);

azure-sdk-for-java:

BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
    .connectionString(connectionString).buildClient();
BlobContainerClient containerClient = blobServiceClient.getBlobContainerClient(containerName);
containerClient.getBlobClient(blobName).upload(InputStream.createFromBytes(data));

Both SDKs provide similar functionality, but the JavaScript version uses Promises for asynchronous operations, while the Java version uses a more traditional blocking approach. The JavaScript SDK also benefits from TypeScript support, offering better type inference and autocompletion in modern IDEs.

This repository is for active development of the Azure SDK for Go. For consumers of the SDK we recommend visiting our public developer docs at:

Pros of azure-sdk-for-go

  • Lightweight and efficient, with a smaller footprint compared to Java
  • Better suited for cloud-native and serverless applications
  • Faster compilation and execution times

Cons of azure-sdk-for-go

  • Less mature ecosystem and fewer third-party libraries
  • Smaller developer community, potentially leading to fewer resources and support
  • Less comprehensive documentation compared to Java SDK

Code Comparison

azure-sdk-for-go:

import (
    "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
    "github.com/Azure/go-autorest/autorest/azure/auth"
)

client := storage.NewAccountsClient(subscriptionID)
authorizer, err := auth.NewAuthorizerFromEnvironment()
client.Authorizer = authorizer

azure-sdk-for-java:

import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.resourcemanager.storage.StorageManager;

StorageManager storageManager = StorageManager
    .authenticate(new DefaultAzureCredentialBuilder().build(), profile)
    .withSubscription(subscriptionId);

Both SDKs provide similar functionality for interacting with Azure services, but the Go SDK tends to have a more concise syntax and lighter resource usage. The Java SDK offers a more object-oriented approach and benefits from Java's extensive ecosystem and tooling support.

The official AWS SDK for Java 1.x. The AWS SDK for Java 2.x is available here: https://github.com/aws/aws-sdk-java-v2/

Pros of aws-sdk-java

  • More comprehensive coverage of AWS services
  • Longer history and larger community, potentially leading to better support and resources
  • Offers both synchronous and asynchronous clients for most services

Cons of aws-sdk-java

  • Larger SDK size, which can increase build times and artifact sizes
  • More complex API structure, potentially steeper learning curve for newcomers
  • Less consistent naming conventions across different services

Code Comparison

aws-sdk-java:

AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
                        .withRegion(Regions.US_WEST_2)
                        .build();
s3Client.putObject(bucketName, key, content);

azure-sdk-for-java:

BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
                        .connectionString(connectionString)
                        .buildClient();
BlobClient blobClient = blobServiceClient.getBlobContainerClient(containerName)
                        .getBlobClient(blobName);
blobClient.upload(content);

Both SDKs provide similar functionality for interacting with their respective cloud storage services. The Azure SDK tends to use a more fluent API style, while the AWS SDK often requires more separate method calls. The Azure SDK also emphasizes the use of builders for client creation, which can lead to more readable code in some cases.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Azure SDK for Java

Packages Build Documentation

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs or our versioned developer docs.

Getting started

To get started with a specific service library, see the README.md file located in the library's project folder. You can find service libraries in the /sdk directory. For a list of all the services we support access our list of all existing libraries.

For tutorials, samples, quick starts and other documentation, visit Azure for Java Developers.

Prerequisites

All libraries are baselined on Java 8, with testing and forward support up until the latest Java long-term support release (currently Java 17).

Available packages

Each service can have both 'client' and 'management' libraries. 'Client' libraries are used to consume the service, whereas 'management' libraries are used to configure and manage the service.

Client Libraries

Our client libraries follow the Azure SDK Design Guidelines for Java, and share a number of core features such as HTTP retries, logging, transport protocols, authentication protocols, etc., so that once you learn how to use these features in one client library, you will know how to use them in other client libraries. You can learn about these shared features here. These libraries can be easily identified by folder, package, and namespaces names starting with azure-, e.g. azure-keyvault.

You can find the most up to date list of all of the new packages on our page. This list includes the most recent releases: both stable and beta.

NOTE: If you need to ensure your code is ready for production use one of the stable, non-beta libraries.

Management Libraries

Similar to our client libraries, the management libraries follow the Azure SDK Design Guidelines for Java. These libraries provide a high-level, object-oriented API for managing Azure resources, that are optimized for ease of use, succinctness, and consistency. You can find the list of management libraries on this page.

For general documentation on how to use the new libraries for Azure Resource Management, please visit here. We have also prepared plenty of code samples as well as migration guide in case you are upgrading from previous versions.

The management libraries can be identified by namespaces that start with azure-resourcemanager, e.g. azure-resourcemanager-compute.

Historical Releases

Note that the latest libraries from Microsoft are in the com.azure Maven group ID, and have the package naming pattern of beginning with com.azure. If you're using libraries that are in com.microsoft.azure Maven group ID, or have this as the package structure, please consider migrating to the latest libraries. You can find a mapping table from these historical releases to their equivalent here.

Need help?

Navigating the repository

Main branch

The main branch has the most recent code with new features and bug fixes. It does not represent latest released stable SDK.

Release branches (Release tagging)

For each package we release there will be a unique git tag created that contains the name and the version of the package to mark the commit of the code that produced the package. This tag will be used for servicing via hotfix branches as well as debugging the code for a particular beta or stable release version. Format of the release tags are <package-name>_<package-version>. For more information please see our branching strategy.

Contributing

For details on contributing to this repository, see the contributing guide.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, view Microsoft's CLA.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Additional Helpful Links for Contributors

Many people all over the world have helped make this project better. You'll want to check out:

Reporting security issues and security bugs

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.

License

Azure SDK for Java is licensed under the MIT license.

Impressions