title | author |
---|---|
The New Azure SDK for .NET |
Presenter Name |
:::::::::::::: {.columns} ::: {.column width="50%"}
Originally, each Azure team built their own .NET SDKs resulting in:
- Many GitHub Repos Across Different Organizations
- Incosistent Operating System Support
- Unique Continuous Integration Processes and Platforms
- Varying Levels of Language/Framework Support
- Inconsistent Package Manager[s] Used
- Undiscoverable API Paradigms
::: ::: {.column width="50%"}
::: ::::::::::::::
::: notes
Each Azure team built their SDKs at different points in their product's maturity
Language, operating system, and package manager support can vary wildly between SDKs
It's also very difficult to discover new APIs as each API uses a different paradigm, naming scheme, GitHub repo structure, and even location on GitHub
:::
:::::::::::::: {.columns} ::: {.column width="50%"}
::: ::: {.column width="50%"}
The new Azure SDK introduces common guidelines that is designed to provide:
- Equitable Operating System Support
- Predictable Language Support
- Consistent Authentication Support
- Universal Continuous Integration Process
- Packages Available in Popular Package Managers
::: ::::::::::::::
::: notes
This is the first step towards applying a common set of standards to all Azure SDKs
Having a common model, makes it easier for new Azure teams to create a discoverable and predictable SDK
Having a core framework in place makes it easier to add support for new languages, operating systems, and package managers in the future
:::
:::::::::::::: {.columns} ::: {.column width="50%"}
- azure/azure-sdk
- Documentation on guidelines and policies
- ➡️ azure/azure-sdk-for-net
- ➡️ SDK for .NET
- azure/azure-sdk-for-js
- SDK for JavaScript
- azure/azure-sdk-for-python
- SDK for Python
- azure/azure-sdk-for-java
- SDK for Java
::: ::: {.column width="50%"}
::: ::::::::::::::
::: notes
The github.com/azure/azure-sdk repository contains releases, documentation, and guidelines for all of the other repositories
The .NET, JavaScript, Python, and Java repositories contain source code, samples, and documentation relevant to that language
Each language repository contains SDK source code to access multiple Azure services in a predictable and consistent manner
:::
:::::::::::::: {.columns} ::: {.column width="50%"}
- github.com/azure/azure-sdk-for-ios
- Client SDK for iOS Apps
- github.com/azure/azure-sdk-for-android
- Client SDK for Android Apps
- github.com/azure/azure-sdk-for-go
- SDK for Go
- github.com/azure/azure-sdk-for-cpp
- SDK for C++
- github.com/azure/azure-sdk-for-c
- SDK for Embedded C
::: ::: {.column width="50%"}
::: ::::::::::::::
::: notes
The underlying guidelines and processes made it easier to add new languages
Each language supports a growing amount of Azure services
:::
::: notes
- Use this link to visit the Azure SDK for .NET GitHub repository: github.com/azure/azure-sdk-for-net.
- Review the contents of the readme.md file.
- Navigate to the samples folder of the source code: github.com/azure/azure-sdk-for-net/~/samples
- Navigate to the API documentation page for the Azure SDK for .NET: github.io/azure/azure-sdk-for-net.
- Navigate to the latest releases page for the Azure SDK: github.io/azure/azure-sdk/~/#net
- Walk through the various Azure services that currently have a preview or generally available client library.
- Navigate to the Gitter community for the Azure SDK for .NET: gitter.im/azure/azure-sdk-for-net.
:::
Developer productivity is the core objective. The overall guidelines and each individual SDK is built around these paradigms:
- Idiomatic
- Each SDK feels natural and conventional to the target language
- Consistent
- SDKs are consistent across various languages and Azure services
- Approachable
- SDKs are well documented with the goal of getting developers started quickly
- Diagnosable
- SDKs feature logging and discoverability as core-level features
- Dependable
- SDKs are stable with a focus on compatibility for seamless upgrades
::: notes
Building SDKs that model these paradigms can help increase developer productivity across all of Azure.
The paradigms are a core part of the underlying guidelines that are used to design each individual SDK.
Many existing SDKs required some rework to implement all five paradigms.
:::
using Microsoft.Azure.Storage;
using Microsoft.Azure.Storage.Blob;
string connectionString = "UseDevelopmentStorage=true";
CloudStorageAccount account = CloudStorageAccount.Parse(connectionString);
CloudBlobClient client = account.CreateCloudBlobClient();
::: notes
NuGet Package: Microsoft.Azure.Storage.Blob
:::
CloudBlobContainer container = client.GetContainerReference("files");
container.CreateIfNotExists();
::: notes
To get a client, you need to create CloudStorageAccount and CloudBlobClient instances
API calls inconsistently support synchronous and asynchronous operations
:::
using Azure.Storage.Blobs;
string connectionString = "UseDevelopmentStorage=true";
BlobServiceClient client = new BlobServiceClient(connectionString);
::: notes
NuGet Package: Azure.Storage.Blobs
:::
BlobContainerClient container = client.GetBlobContainerClient("files");
await container.CreateIfNotExistsAsync();
::: notes
The new SDK supports both synchronous and asynchronous API calls consistently
The SDK also renames the classes to be consistent across languages while respecting each individual languages' idiomatic standards
:::
::: notes
Prerequisites: Ensure you have .NET 5 or higher installed.
-
Open a new instance of Visual Studio Code in an empty folder.
-
If you have not already, install the [Azure Storage][visualstudio.com/ms-azuretools.vscode-azurestorage] extension for Visual Studio Code.
-
If you have not already, install the [Azurite][visualstudio.com/azurite.azurite] extension for Visual Studio Code.
-
Open a new terminal and perform the following actions:
-
Install the Preview.CSharp.Templates project template package from NuGet:
dotnet new --install Preview.CSharp.Templates
-
Initialize an empty top-level program using the dotnet CLI:
dotnet new script-empty
-
Install the Azure.Storage.Blobs package from NPM:
dotnet add package Azure.Storage.Blobs
-
-
Open the Program.cs file in the editor.
-
Create a using directive for the Azure.Storage.Blobs namespace:
using Azure.Storage.Blobs;
-
Create a variable named connectionString of type string with a value of "UseDevelopmentStorage=true":
string connectionString = "UseDevelopmentStorage=true";
-
Create a variable named client of type BlobServiceClient that stores the result of invoking the constructor of the BlobServiceClient class passing in the connectionString variable as a parameter:
BlobServiceClient client = new BlobServiceClient(connectionString);
-
Create a variable named container of type BlobContainerClient that stores the result of invoking the GetBlobContainerClient method of the client variable passing in the value "files" as a parameter:
BlobContainerClient container = client.GetBlobContainerClient("files");
-
Asynchronously invoke the CreateIfNotExistsAsync method of the container variable:
await container.CreateIfNotExistsAsync();
-
Save your changes to the Program.cs file.
-
Start the Azurite emulator using either the option on the status bar or the
Azurite: Start
command in the Command Palette. -
In the Activity Bar, navigate to the Azure option.
-
In the document tree within the Azure pane, expand the following nodes: Storage => Attached Storage => Local Emulator => Blob Containers.
-
Open a new terminal and run the .NET application:
dotnet run
-
Back in the Azure pane, open the context menu for the Blob Containers node and then select Refresh.
-
Observe the newly created files container in the document tree.
:::