Startup.ConfigureServices: services.AddSwaggerGen(c => c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" }));
Enable middleware & set-up json UI in Startup.Configure:
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
<GenerateDocumentationFile>true</GenerateDocumentationFile><NoWarn>$(NoWarn);1591</NoWarn> in .csproj.In Startup.ConfigureServices enable XML documents via reflection:
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"));
<summary> and <param name ="id"> tags.[Required] or [DefaultValue(false)][Produces("application/json")][ProducesResponseType(201)] and then document with <response code="201"/> XML tag.StatelessService
StatelessServicefabric:/ scheme such as fabric:/MyApp/MyService Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force -Scope CurrentUser
HelloWorldHelloWorldStatelessHelloWorld: Application project that contains services and some PowerShell scripts that help you to deploy your application.HelloWorldStateless: Service project, contains stateless service implementation.You begin executing workloads, including long-running compute workloads.
protected override async Task RunAsync(CancellationToken cancellationToken)
{
...
}
A cancellation token is provided to coordinate when your service instance needs to be closed.
RunAsync() as quickly as possible when the system requests cancellation.You can plug in your communication stack of choice, e.g. start receiving requests (e.g. via ASP .NET Core) from users and other services.
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
...
}
HelloWorldHelloWorldStatefulReliable Queue, perform an operation on it, and save the result in a Reliable Dictionary, all within a single transaction.RunAsync(). This work can include ensuring that the Reliable State Manager and Reliable Collections are ready to use.Code example:
c#
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");
ServiceEventSource.Current.ServiceMessage(this.Context, "Current Counter Value: {0}",result.HasValue ? result.Value.ToString() : "Value does not exist.");
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);
}
az group create --name myAKSCluster --location eastusaz aks create --resource-group myAKSCluster --name myAKSCluster --node-count 1 --enable-addons monitoring --generate-ssh-keysaz aks get-credentials --resource-group myAKSCluster --name myAKSClusterkubectl get nodes
az aks install-cli command.az group create --name myResourceGroup --location eastusaz acr create --resource-group myResourceGroup --name myContainerRegistry007 --sku Basic
az acr login --name <acrName> docker pull microsoft/aci-helloworld
az acr list --resource-group myResourceGroup --query "[].{acrLoginServer:loginServer}" --output table
docker tag microsoft/aci-helloworld <acrLoginServer>/aci-helloworld:v1
docker push <acrLoginServer>/aci-helloworld:v1
az acr repository list --name <acrName> --output table
az acr repository show-tags --name <acrName> --repository aci-helloworld --output tableaz acr update --name <acrName> --admin-enabled true
az acr credential show --name <acrName> --query "passwords[0].value"az container create --resource-group myResourceGroup --name acr-quickstart --image <acrLoginServer>/aci-helloworld:v1 --cpu 1 --memory 1 --registry-username <acrName> --registry-password <acrPassword> --dns-name-label aci-demo --ports 80az container show --resource-group myResourceGroup --name acr-quickstart --query instanceView.stateaz container show --resource-group myResourceGroup --name acr-quickstart --query ipAddress.fqdnaz acr login --name myregistrydocker tag nginx myregistry.azurecr.io/samples/nginxdocker push myregistry.azurecr.io/samples/nginx