PROBLEM
I am using the code below to generate a SAS URI for a Azure Storage Account which works a treat.
However when executing the code the resulting console application window displays the relevant URI string but I am unable to copy the value.
QUESTION
Easy question hopefully , what has to be added to the code below to output the URI to a text file ?
{
using System.IO;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; using System.Threading.Tasks;
namespace SAS
{ class Program { static void Main(string[] args) {
//Parse the connection string and return a reference to the storage account. CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString")); //Create the blob client object. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); //Get a reference to a container to use for the sample code, and create it if it does > not exist. CloudBlobContainer container = blobClient.GetContainerReference("sascontainer"); container.CreateIfNotExists(); //Insert calls to the methods created below here... //Generate a SAS URI for the container, without a stored access policy. Console.WriteLine("Container SAS URI: " + GetContainerSasUri(container)); Console.WriteLine(); //Require user input before closing the console window. Console.ReadLine(); } static string GetContainerSasUri(CloudBlobContainer container) { //Set the expiry time and permissions for the container. //In this case no start time is specified, so the shared access signature > becomes valid immediately. SharedAccessBlobPolicy sasConstraints = new SharedAccessBlobPolicy(); sasConstraints.SharedAccessExpiryTime = DateTime.UtcNow.AddHours(4); sasConstraints.Permissions = SharedAccessBlobPermissions.Write | > SharedAccessBlobPermissions.List; //Generate the shared access signature on the container, setting the > constraints directly on the signature. string sasContainerToken = > container.GetSharedAccessSignature(sasConstraints); //Return the URI string for the container, including the SAS token. return container.Uri + sasContainerToken; } }
} }