Upload
enkelejda-derraj
View
225
Download
0
Embed Size (px)
Citation preview
7/28/2019 Cloud Services in mobile apps
1/50
Ndertimi iaplikimevemobile dukeperdorurCloudservices per
7/28/2019 Cloud Services in mobile apps
2/50
7/28/2019 Cloud Services in mobile apps
3/50
Nje cloud service konsiston ne nje ose me shume web
roles dhe/ose worker roles, secili me skedaret e
aplikimit dhe konfigurimin e vete.
Cdo sherbim cloud ka dy mjedise
ku mund te shperndash paketen e
sherbimit dhe konfigurimin.
Mjedisi prezantues per ta testuar, para se ta
promovosh ne prodhim.Promovimi i sherbimeve cloud nga mjedisi
prezantues ne prodhim eshte shume i thjeshte,
ndryshohen adresat IP virtuale (VIP) qe jane te
lidhura me dy mjediset.
7/28/2019 Cloud Services in mobile apps
4/50
7/28/2019 Cloud Services in mobile apps
5/50
7/28/2019 Cloud Services in mobile apps
6/50
Windows Azure eshte nje platforme dhe infrastructure
cloud computing, krijuar nga Microsoft, per ndertimin ,
shperndarjen dhe menaxhimin e aplikacioneve dhe
sherbimeve (services) permes nje rrjeti global tedatacenters te menaxhuara nga Microsoft.
http://en.wikipedia.org/wiki/Cloud_computinghttp://en.wikipedia.org/wiki/Cloud_computing7/28/2019 Cloud Services in mobile apps
7/50
Enqueue
Dequeue Msg
asinkrone te
qendrueshe
m
Multimedia Skedare te
medhenj
Ruajtje estrukturuar e
database jo-
relacionale
Pershkallezi
m masiv
Database
relacionale
7/28/2019 Cloud Services in mobile apps
8/50
Ne Qershor 2012. Windows Azure nxorri karakterisitkat e meposhtme:
Website-tet lejojne zhvilluesit te ndertojne site duke perdorur ASP.NET, PHP
ose Node.js, dhe mund te shperndahen duke perdorur FTP, Git ose Team
Foundation Server.
Makinat virtuale, lejojne te migrohen aplikacionet dhe infrastruktura pa
ndryshuar kodin, dhe mund te ekzekutohen ne Windows Server dhe makinat
virtuale te Linux.
Cloud Services- mjedisi i Microsoft per PaaS, qe perdoret per te krijuar
aplikacione dhe sherbime te pershkallezueshme. Suporton skenare shume-
shtresor dhe shpernarje te automatizuara.
Data Management( Menaxhimi it e Dhenave) baza e te dhenave SQL, njohur
si SQL Azure, punon per te krijuar , pershkallezuar dhe zgjeruar aplikacionetne cloud duke perdorur teknologjine e Microsoft SQL Server. Integrohet me
Active Directory, Microsoft System Center dhe Hadoop.
Media services- nje Paas qe mund te perdoret per kodim, mbrojtjen e
permbajtjes, streaming si dhe per analiza.
7/28/2019 Cloud Services in mobile apps
9/50
Sherbimet cloud ofrojne
PaaS.
Kjo teknologji eshte
dizenjuar per te
mbeshtetur aplikacioneqe jane te
pershkallezueshme, te
besueshme, dhe te lira per
tu operuar.
Figure: Windows Azure Cloud Services provides Platform as a Service.
Cloud Services mbeshteten ne . Teknologjia ofron dy opsione te VM:
1. Instancat e web roles punojne me nje variant Windows Server me IIS
2. worker roles punojne me te njejtin variant te Windows Server , por pa IIS.
Nje aplikacion i sherbimeve cloud mbeshtetet ne nje kombinim te dy opsioneve.
Prsh. Nje aplikacion i thjesht mund te perdore vetem nje web role, ndersa nje me i
komplikuar mund te perdore web role per te menaxhuar kerkesat e perdoruesve, me pas
punen e krijuar nga ato kerkesa tia kalojne nje worker role, per procesim. (ky komunikimmund te perdore Service Bus ose Windows Azure Queues).
7/28/2019 Cloud Services in mobile apps
10/50
Ashtu si tregohen edhe ne figure, te gjitha VM-te e nje aplikacioni te
vetem , ekzekutohen ne te njejtin sherbim cloud.
Prandaj perdoruesit e aksesojne aplikacionin permes nje adrese publike
IP te vetme, me kerkesat qe automatikisht ngarkohen ne menyre te
balancuar pergjate VM-ve te aplikacionit.
Dhe meqe sherbimet cloud krijohen duke perdorur Makinat Virtuale te
Windows Azure, platform do i shperndaje VM-te ne nje aplikacion Cloud
Services, ne nje menyre qe shmang prishjen e hardware-it ne nje pike te
vetme
Me Cloud Services, nuk krijon makina virtuale, por ti ofron nje skedar
konfigurimi qe i thote Windows Azure sa te duhen nga secila, si prsh 3
instanca te web role dhe 2 te worker role, dhe ato krijohen nga
platforma.Ti zgjedh cfare madhesie do kene keto VM.
Nqs aplikacioni ka nevoje per ngarkim me te madh, kerkon per VM
te tjera dhe Windows Azure do krijoje instancat e kerkuara.
Nqs ngarkimi zvogelohet, atehere mund ti ndalosh ato instanca dhe
te mos paguash me per to.
7/28/2019 Cloud Services in mobile apps
11/50
7/28/2019 Cloud Services in mobile apps
12/50
Windows Azure Mobile Services
eshte nje sherbim i Windows Azure
qe ofron nje menyre te thjeshte perte krijuar aplikacione mobile me
funksionalitet te larte duke
perdorur Windows Azure.
Ai ofron nje pakete te sherbimeve
te Windows Azure ne lidhje me
kapacitetin backend te
aplikacioneve .
7/28/2019 Cloud Services in mobile apps
13/50
Ofron keto kapacitete:
Client libraries suportojne zhvillimin e aplikacioneve mobile ne pajisje te ndryshme,
perfshire Windows 8, Windows Phone 8, iPhone, and iPad.
Menaxhim i thjesht i tabelave per ruajtjen e te dhenave.
Integrim me sherbimet e njoftimeve per te shperndare njoftimet push ne app tuaj.
Integrim me ofruesit e njohur te identitetit per autentifikim.
Kontroll i imtesishem per te autorizuar aksesin ne tabela.
Suporton scripte per te futur logjiken e biznesit ne operacionet e aksesimit te te
dhenave.
Integrim me sherbime te tjera cloud.
Ofron aftesin e pershkallezimit te instancave te sherbimit mobile.
Monitorim dhe dokumentim te sherbimit.
7/28/2019 Cloud Services in mobile apps
14/50
Windows Azure Mobile Services e ben shume te thjeshte lidhjen midis nje backend-
i te pershkallezueshem ne cloud dhe aplikacioneve klient dhe mobile.
Lejon te ruani te dhena te strukturuara ne cloud te cilat mund te bashkojne pajisjet
me perdoruesit, integrojne me autentifikimin e perdoruesit, si dhe te dergojne
perditesime klienteve nepermjet njoftimeve push.
7/28/2019 Cloud Services in mobile apps
15/50
Storing Data in the Cloud
Ruajtja e te dhenave ne cloud me Windows Azure Mobile Services eshte shume e
thjeshte.
Kur krijon nje Windows Azure Mobile Service, ai lidhet automatikisht me nje database
SQL brenda Windows Azure.
Me pas Windows Azure Mobile Service backend ofron suport built-in per te lejuarapps remote te ruajne te dhena si dhe ti aksesojne ato ne menyre te sigurte - pa pasur
nevoje te shkruani apo shperndani server code manualisht.
Brenda portalit te Windows Azure ofrohet edhe menaxhimi Built-in , per krijimin e
tabelave te reja, kerkimin e te dhenave, caktimin e indekseve si dhe kontrolli i lejeve te
aksesit.
7/28/2019 Cloud Services in mobile apps
16/50
Menaxhimi dhe monitorimi i sherbimeve mobile:
Mund te monitorosh perdorimin dhe metrikat e sherbimit mobile duke
perdorur tab-in Dashboard
Tabi dashboard ofron
nje pamje monitoruese
built-in te thirrjeve te
API-t, Bandwidth, dhe
ciklet e CPU se serverit
te Windows Azure
Mobile Service.
Gjithashtu mund te
perdorni tabin Logs
per te pare mesazhe
gabimi .Ne kete menyre behet e
lehte monitorimi i
mbarvajtjes se
aplikacionit tuaj.
http://www.gophoto.it/view.php?i=http://weblogs.asp.net/blogs/scottgu/image_2127FDCE.png7/28/2019 Cloud Services in mobile apps
17/50
7/28/2019 Cloud Services in mobile apps
18/50
7/28/2019 Cloud Services in mobile apps
19/50
7/28/2019 Cloud Services in mobile apps
20/50
7/28/2019 Cloud Services in mobile apps
21/50
7/28/2019 Cloud Services in mobile apps
22/50
Do tregohet si mund te shtoni
nje sherbim backend i bazuar
ne cloud, ne nje app Windows
Phone 8 , duke perdorur
Windows Azure Mobile
Services. Do krijoni nje
sherbim mobile dhe nje app tethjeshte To do listqe ruan te
dhenat ne sherbimin e krijuar.
Tregohet app i perfunduar
7/28/2019 Cloud Services in mobile apps
23/50
1.Logohu ne Portalin e Menaxhimit.
2. ne fund te panelit te navigimit kliko +NEW.
3. Hap Compute dhe Mobile Service, dhe kliko Create.
Do shfaqet kutia e dialogut New Mobile Service .
Krijo nje sherbim mobile
7/28/2019 Cloud Services in mobile apps
24/50
Ne faqen Create a mobile service , shkruaj nje emer per subdomain in esherbimit te ri mobile , ne textbox URL dhe prit derisa te verifikohet.Me pas kliko shigjeten per te shkuar ne faqen tjeter.
Shfaqet faqja Specify database settings .
7/28/2019 Cloud Services in mobile apps
25/50
Name, emri i database, Login name, qe eshte emri i administratorit per serverinSQL Database te ri. Shkruaj passwordin dhe konfirmoje, dhe kliko butonin checkper te perfunduar.
7/28/2019 Cloud Services in mobile apps
26/50
1. Ne Portalin e Menaxhimit, kliko Mobile Services, dhe kliko sherbimin qe sapo krijuam.2. Ne tabin quickstart , kliko Windows Phone 8 nen Choose platform dhe hap Create a newWindows Phone 8 App
Krijimi i nje app Windows Phone
7/28/2019 Cloud Services in mobile apps
27/50
Shfaqen 3 hapa te thjeshte per te krijuar Windows Phone app , te lidhur me sherbimin
mobile
3. Shkarko dhe instalo Visual Studio 2012 Express for Windows Phone.
4. Kliko Create TodoItem table per te krijuar tabelen qe do ruaje te dhenat e app.
5. Nen Download and run app, kliko Download.
Ne kete menyre do shkakrohet projekti me shembullin To do listapp .
https://go.microsoft.com/fwLink/p/?LinkID=268374https://go.microsoft.com/fwLink/p/?LinkID=268374https://go.microsoft.com/fwLink/p/?LinkID=2683747/28/2019 Cloud Services in mobile apps
28/50
1.Gjej folderin qe shkarkove(te shembullit) dhe hap skedarin solution ne Visual Studio2012 Express per Windows Phone.
Ekzekutimi i Windows Phone app
7/28/2019 Cloud Services in mobile apps
29/50
4. Kthehu ne Portalin e Menaxhimit, kliko tabin Data dhe me pas
tabelen TodoItems
Ne Browse shfaqen te dhenat qe u futen
7/28/2019 Cloud Services in mobile apps
30/50
7/28/2019 Cloud Services in mobile apps
31/50
Mobile Services perdorin nje baze te dhenash SQl per ruajtjen e te dhenave.
Megjithate , te dhenat BLOB ( Binary Large Object) ruhen ne menyre me
eficente ne sherbimin blob storage te Windows Azure.
Me ane te aplikacionit klient nuk mund shperndash ne menyre te sigurte,
kredencialet e kerkuara , per te ngarkuar ne menyre te sigurte te dhena ne
sherbimin Blob Storage.
Kredencialet ruhen ne skripte te serverit dhe perdoren per te gjeneruarSAS(Shared Access Signature) , e cila perdoret per ngarkimin e nje imazhi
te ri.
SAS eshte nje kredencial me kohe te limituar ( e percaktojme ne) i
kthehet aplikacionit klient ne menyre te sigurte nga sherbimet mobile.
Me pas aplikacioni perdor kete kredencial te perkoheshem, per te
ngarkuar imazhin.
7/28/2019 Cloud Services in mobile apps
32/50
Instalimi i Storage client per Windows Store apps
1. Shkarko Storage client library for Windows Store apps dhe extracto skedaret ne
kompjuterin lokal.
2. Ne menune Project ne Visual Studio, kliko Add Reference, dhe me pas klikoBrowse.
3. Kerko ne vendin qeekstraktove skedaret kliko
skedarinMicrosoft.WindowsAzure.Sto
rage.winmd kliko Add, dheme pasOK.Ne kete menyre shtohet njereference e Storage Client
Library ne projekt.Me pas, do update-oniaplikacionin quickstart appper te kapur dhe ngarkuarimazhe.
7/28/2019 Cloud Services in mobile apps
33/50
Ndryshimi i scriptit insert te regjistruar ne Portalin e Menaxhimit
1. Ne Portalin e Menaxhimit, kliko Storage, kliko storage account, me pas Manage Keys
7/28/2019 Cloud Services in mobile apps
34/50
2. Shkruaj Storage Account Name dhe Access Key.
7/28/2019 Cloud Services in mobile apps
35/50
3. Ne sherbimin tuaj mobile kliko tabin Data dhe me pas kliko tabelen TodoItem.
7/28/2019 Cloud Services in mobile apps
36/50
4. Ne todoitem, kliko tabin Script dhe zgjidh Insert.
Kjo shfaq funksionin qe thirret kur ndodh nje insert ne tabelen TodoItem.
7/28/2019 Cloud Services in mobile apps
37/50
5. Zevendeso funksionin insert me kodin e meposhtem:
var azure = require('azure');
var qs = require('querystring');
function insert(item, user, request) {
var accountName = '';
var accountKey = '';var host = accountName + '.blob.core.windows.net';
var canonicalizedResource = '/' + item.containerName +
'/' + item.resourceName;
if ((typeof item.containerName !== "undefined") && (
item.containerName !== null)) {
// Set the BLOB store container name on the item,
which must be lowercase.
item.containerName =
item.containerName.toLowerCase();// If it does not already exist, create the container with
public read access for blobs.
var blobService = azure.createBlobService(accountName,
accountKey, host);
blobService.createContainerIfNotExists(item.containerNam
e, {
publicAccessLevel: 'blob'
}, function(error) {
if (!error) {
// Provide write access to the container for the next 5 mins.
var sharedAccessPolicy = {
AccessPolicy: {
Permissions:
azure.Constants.BlobConstants.SharedAccessPermissions.WRITE,Expiry: new Date(new Date().getTime() + 5 * 60 * 1000)
}
};
// Generate the upload URL with SAS for the new image.
var sasQueryUrl =
blobService.generateSharedAccessSignature(item.containerName,
item.resourceName, sharedAccessPolicy);
// Set the query string.item.sasQueryString = qs.stringify(sasQueryUrl.queryString);
// Set the full path on the new new item, which is used for
data binding on the client.
item.imageUri = sasQueryUrl.baseUrl + sasQueryUrl.path;
} else {
console.error(error);
}
request.execute();
});
} else {
request.execute();
} }
Ky script gjeneron nje SAS te ri per insertin, i vlefshem per 5 minuta, dhe i cakton vleren e SAS tegjeneruar , property-is sasQueryString te item te kthyer.Property imageUri, gjithashtu caktohet ne pathin burim te BLOB te ri, per te lejuar shfaqjen e imazhit gjatelidhjes (binding) ne nderfaqen e klientit.
7/28/2019 Cloud Services in mobile apps
38/50
6. Ne skriptin e mesiperm,zevendeso vlerat e dhe me ato qe percaktove ne hapin e 2 , me pasklikoSave.
7/28/2019 Cloud Services in mobile apps
39/50
Update app klient quickstart per te kapur dhe ngarkuar imazhe
1. Ne Visual Studio 2012, hap skedarin Package.appxmanifest dhe ne
tabin Capabilities zgjidh Webcam dhe Microphone .
Kjo siguron qe aplkiacioni mund te perdori nje kamera te lidhur me kompjuterin. Perdoruesve
do i kerkohet te lejojne aksesin e kameras heren e pare qe do ekzekutojne app-in.
7/28/2019 Cloud Services in mobile apps
40/50
2. Hap skedarin MainPage.xaml dhe zevendeso elementin StackPanel direct
pas elementit te pare Task me kodin e meposhtem:
7/28/2019 Cloud Services in mobile apps
41/50
3. Zevendeso elementin StackPanel ne DataTemplate me
kodin:
Ne kete menyre shtohet nje imazh ne ItemTemplate dhe caktohet
burimi i lidhjes ne shebimin Blob Storage si URI i imazhit te ngarkuar.
7/28/2019 Cloud Services in mobile apps
42/50
4. Hap skedarin projekt MainPage.xaml.cs dhe shto keto rreshta :
using Windows.Media.Capture;
using Windows.Storage;
using Windows.UI.Popups;using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
5. Ne klasen TodoItem class, shto propertit e meposhtme:
[DataMember(Name = "containerName")]
public string ContainerName { get; set; }
[DataMember(Name = "resourceName")]
public string ResourceName { get; set; }
[DataMember(Name = "sasQueryString")]
public string SasQueryString { get; set; }
[DataMember(Name = "imageUri")]
public string ImageUri{ get; set; }
7/28/2019 Cloud Services in mobile apps
43/50
6. Ne klasen MainPage class, shto kodin e meposhtem:
// Use a StorageFile to hold the captured image for upload.
StorageFile media = null;
private async void OnTakePhotoClick(object sender, RoutedEventArgs e)
{
// Capture a new photo or video from the device.
CameraCaptureUI cameraCapture = new CameraCaptureUI();
media = await cameraCapture
.CaptureFileAsync(CameraCaptureUIMode.PhotoOrVideo);
}
Ky kod shfar nderfaqen e kameresper te kapur nje imazh, dhe ruan imazhin
ne nje skedar.
7 Zevendeso metoden InsertTodoItem me kodin e meposhtem:
7/28/2019 Cloud Services in mobile apps
44/50
7. Zevendeso metoden InsertTodoItem me kodin e meposhtem:
private async void InsertTodoItem(TodoItem todoItem)
{
string errorString = string.Empty;
if (media != null)
{
// Set blob properties of TodoItem.todoItem.ContainerName = "todoitemimages";
todoItem.ResourceName = media.Name;
}
// Send the item to be inserted. When blob properties are set this generates an SAS in the response.
await todoTable.InsertAsync(todoItem);
// If we have a returned SAS, then upload the blob.
if (!string.IsNullOrEmpty(todoItem.SasQueryString))
{ // Get the new image as a stream.
using (var fileStream = await media.OpenStreamForReadAsync())
{
// Get the URI generated that contains the SAS and extract the storage credentials.
StorageCredentials cred = new StorageCredentials(todoItem.SasQueryString);
var imageUri = new Uri(todoItem.ImageUri);
// Instantiate a Blob store container based on the info in the returned item.
CloudBlobContainer container = new CloudBlobContainer(
new Uri(string.Format("https://{0}/{1}",imageUri.Host, todoItem.ContainerName)), cred);
// Upload the new image as a BLOB from the stream.
CloudBlockBlob blobFromSASCredential =
container.GetBlockBlobReference(todoItem.ResourceName);
await blobFromSASCredential.UploadFromStreamAsync(fileStream.AsInputStream());
}
}
// Add the new item to the collection.
items.Add(todoItem);}
Ky kod dergon nje kerkese ne sherbimin
mobile per te shtuar nje TodoItem te re,
perfshire emrin e skedarit te imazhit.
Pergjigjia permban SAS-n, e cila perdoret
per te future imazhin ne Blob, dhe URI i
imazhit qe perdoret per lidhjen e te
dhenave.
7/28/2019 Cloud Services in mobile apps
45/50
Tesimi i njoftimeve push ne app
1. Ne Visual Studio, shtyp tastin F5 per te ekzekutuar aplikacionin.
2. Fut tekst ne textbox nen Insert a TodoItem, me pas kliko Photo.
Kjo shfaq nderfaqen
e kameres.
3. Kliko imazhin per
te bere nje foto, me
pas kliko OK.
7/28/2019 Cloud Services in mobile apps
46/50
4. Kliko Upload per te shtuar item e ri dhe per te ngarkuar imazhin.
5. Itemi i ri , bashke me imazhin e ngarkuar shfaqet ne liste.
7/28/2019 Cloud Services in mobile apps
47/50
PROJECT HAWAII CLOUD SERVICES
Ne Project Hawaii SDK perfshiehn Cloud Services e meposhtme:
7/28/2019 Cloud Services in mobile apps
48/50
Relay Service
Ky sherbim ofron nje pike abstrakte ne cloud qe aplikacionet mobile mund ta perdorin
per te komunikuar. Ofron nje pike fundore bufferi per msg te derguar midis nje ose me
shume pikave fundore.
Rendezvous Service
Ky eshte nje sherbim mapping nga emra te njohur te lexueshem nga njeriu ne pika
fundore te Hawaii Relay Service. Perdor emra te njohur te lexueshem nga njeriu si pika
takimi te qendrueshme qe mund te kompilohen ne aplikacione.
Optical Character Recognition (OCR) Service
Ky sherbim merr nje imazh fotografik qe permban tekst dhe kthen teksitn. Prsh nqs
jepet ne imazh JPEG i nje shenje rrugore, sherbimi do ktheje tekstin e shenjes.
Speech-to-Text Service
Ky sherbim merr nje shprehje te folur dhe e kthen ne tekst (aktualisht vetem neAnglisht)
This service takes a spoken phrase and returns text (currently in English only).
7/28/2019 Cloud Services in mobile apps
49/50
intelligentME
Aktualisht ne te gjithe kryejme disa rutina ne venda te caktuara. Prsh.
1) Dergojme SMS dikujt kur arrijme ne shtepi
2) vendosim telefonin ne modalitet te heshtur kur jemi ne teate/kinema/shkolle.
3) eksekutojme app te caktuara ne vende te caktuara (prsh. bus arrival app ne ndalesen e
autobuzit).
Meqe ekziston nje lidhje mes vendodhjes dhe listes se veprimeve per te cilat duam qe telefoni
yne te kryeje, ath do ishte mire ndertimi i nje app i ndjeshem ndaj vendndodhjes, kjo do
ndryshoje menyren si njerezit perdorin smartphone-et e tyre.
7/28/2019 Cloud Services in mobile apps
50/50