gebeurtenis
17 mrt, 21 - 21 mrt, 10
Neem deel aan de meetup-serie om schaalbare AI-oplossingen te bouwen op basis van praktijkgebruiksvoorbeelden met collega-ontwikkelaars en experts.
Nu registrerenDeze browser wordt niet meer ondersteund.
Upgrade naar Microsoft Edge om te profiteren van de nieuwste functies, beveiligingsupdates en technische ondersteuning.
Azure Service Fabric is a distributed systems platform that makes it easy to package, deploy, and manage scalable and reliable microservices and containers. For more information, see the Azure Service Fabric Documentation.
Use the Service Fabric client library to interact with an existing Service Fabric cluster. The library contains three categories of APIs:
Install the NuGet package directly from the Visual Studio Package Manager console or with the .NET Core CLI.
Install-Package Microsoft.ServiceFabric
dotnet add package Microsoft.ServiceFabric
The following example uses the Service Fabric client APIs to copy an application package to the image store, provisions the application type, and create an application instance.
/* Include these dependencies
using System.Fabric;
using System.Fabric.Description;
*/
// Connect to the cluster.
FabricClient fabricClient = new FabricClient(clusterConnection);
// Copy the application package to a location in the image store
fabricClient.ApplicationManager.CopyApplicationPackage(imageStoreConnectionString, packagePath, packagePathInImageStore);
// Provision the application.
fabricClient.ApplicationManager.ProvisionApplicationAsync(packagePathInImageStore).Wait();
// Create the application instance.
ApplicationDescription appDesc = new ApplicationDescription(new Uri(appName), appType, appVersion);
fabricClient.ApplicationManager.CreateApplicationAsync(appDesc).Wait();
This example uses the Service Fabric runtime and common APIs from within a hosted application to update a Reliable Collection at runtime.
using System.Fabric;
using Microsoft.ServiceFabric.Data.Collections;
using Microsoft.ServiceFabric.Services.Communication.Runtime;
using Microsoft.ServiceFabric.Services.Runtime;
/// <summary>
/// This is the main entry point for your service replica.
/// This method executes when this replica of your service becomes primary and has write status.
/// </summary>
/// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service replica.</param>
protected override async Task RunAsync(CancellationToken cancellationToken)
{
var myDictionary = await this.StateManager.GetOrAddAsync<IReliableDictionary<string, long>>("myDictionary");
while (true)
{
cancellationToken.ThrowIfCancellationRequested();
using (var tx = this.StateManager.CreateTransaction())
{
var result = await myDictionary.TryGetValueAsync(tx, "Counter");
await myDictionary.AddOrUpdateAsync(tx, "Counter", 0, (key, value) => ++value);
// If an exception is thrown before calling CommitAsync, the transaction aborts, all changes are
// discarded, and nothing is saved to the secondary replicas.
await tx.CommitAsync();
}
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
}
}
The management library is used to create, update, and delete Service Fabric clusters.
Install the NuGet package directly from the Visual Studio Package Manager console or with the .NET Core CLI.
Install-Package Microsoft.Azure.Management.ServiceFabric
dotnet add package Microsoft.Azure.Management.ServiceFabric
Azure SDK for .NET-feedback
Azure SDK for .NET is een open source project. Selecteer een koppeling om feedback te geven:
gebeurtenis
17 mrt, 21 - 21 mrt, 10
Neem deel aan de meetup-serie om schaalbare AI-oplossingen te bouwen op basis van praktijkgebruiksvoorbeelden met collega-ontwikkelaars en experts.
Nu registreren