public async Task <string> GetHostIdAsync(CancellationToken cancellationToken) { CloudStorageAccount account; try { account = _storageAccountProvider.GetStorageAccount(); } catch (InvalidOperationException exception) { throw new InvalidOperationException( "A host ID is required. Either set JobHostConfiguration.HostId or provide a valid storage " + "connection string.", exception); } IFunctionIndex index = await _getFunctionIndexProvider.GetAsync(cancellationToken); IEnumerable <MethodInfo> indexedMethods = index.ReadAllMethods(); string sharedHostName = GetSharedHostName(indexedMethods, account); var directory = account.CreateCloudBlobClient().GetContainerReference( HostContainerNames.Hosts).GetDirectoryReference(HostDirectoryNames.Ids); return(await GetOrCreateHostIdAsync(sharedHostName, directory, cancellationToken)); }