스테이징 또는 운영 인스턴스?
서비스 런타임에 현재 'Staging' 또는 'Production'에서 실행 중인지 알 수 있는 곳이 있습니까?실제 가동 환경에서 수동으로 설정을 변경하는 것은 다소 번거로운 작업인 것 같습니다.
Prod 또는 Staging을 기반으로 할 때는 구성을 변경하지 마십시오.스테이징 영역은 "QA" 환경으로 설계되지 않고 실전 배치 전 보류 영역만 설계됩니다.
새 배포를 업로드하면 패키지를 업로드하는 현재 배포 슬롯이 삭제되고 VM 업로드 및 시작 중에 10-15분 동안 중단됩니다.실제 가동 환경에 직접 업로드하면 운영 중단 시간이 15분이나 됩니다.따라서 스테이징 영역이 발명되었습니다.스테이징에 업로드하여 테스트하고 "Swap" 버튼을 클릭하면 스테이징 환경이 마법처럼 운영(가상 IP 스왑) 상태가 됩니다.따라서 스테이징은 실제 가동과 100% 같아야 합니다.
QA/테스트 환경을 원하십니까?자체 Prod/Staging을 사용하여 테스트 환경을 위한 새로운 서비스를 오픈해야 합니다.이 경우 도입 환경(실가동, 테스트 등)별로 1세트씩 여러 구성 파일 세트를 유지해야 합니다.
Config 파일 위에 자체 *.cscfg 파일이 있는 Azure에서는 특히 발생하는 구성 지옥을 관리하는 여러 가지 방법이 있습니다.Azure 프로젝트에서 원하는 방법은 다음과 같습니다.소규모 구성 프로젝트를 설정하고 배포 유형과 일치하는 폴더를 만듭니다.각 폴더 셋업 세트에는 특정 전개 환경에 일치하는 *.config 파일 및 *.cscfg 파일(Debug, Test, Release...)이 포함되어 있습니다.Visual Studio에서도 빌드 대상 유형으로 설정됩니다.Config 프로젝트의 모든 컴파일 중에 Config 프로젝트의 Build Target 폴더에서 Config 프로젝트의 루트 폴더로 모든 파일을 복사하는 작은 xcopy 명령어가 있습니다.
그런 다음 솔루션 내의 다른 모든 프로젝트를 구성 프로젝트의 루트 폴더에서 .config 또는 .cscfg 파일로 링크합니다.
Voila, 내 구성은 마법처럼 모든 빌드 구성에 자동으로 적응합니다.또한 .config 변환을 사용하여 Release 빌드 타깃과 비Release 빌드 타깃의 디버깅 정보를 관리합니다.
이 모든 것을 읽었는데도 실제 가동과 실행 시 스테이징 상태: 가져오기deploymentId
부에서RoleEnvironment.DeploymentId
그러면 적절한 런 음 리 절 API를 사용하여 관리 API를 사용합니다.X509 certificate
to get at the 에 접근하다Azure structure of your Service
and call the 에 전화합니다.GetDeployments
방법이 있지만 추상적인 API가 있습니다.method(rest api이지만 추상화 라이브러리가 있음)
도움이 되었으면 좋겠다
편집: 설정 문자열 설정 및 환경 간 전환에 대한 요청에 따라 블로그에 게시 http://blog.paraleap.com/blog/post/Managing-environments-in-a-distributed-Azure-or-other-cloud-based-NET-solution
가끔 사람들이 그냥 질문에 대답해주길 바란다.윤리나 베스트 프랙티스를 설명하지 않는다...
Microsoft 에서는, 다음의 URL 에 코드 샘플을 게재하고 있습니다.https://code.msdn.microsoft.com/windowsazure/CSAzureDeploymentSlot-1ce0e3b5
protected void Page_Load(object sender, EventArgs e)
{
// You basic information of the Deployment of Azure application.
string deploymentId = RoleEnvironment.DeploymentId;
string subscriptionID = "<Your subscription ID>";
string thrumbnail = "<Your certificate thumbnail print>";
string hostedServiceName = "<Your hosted service name>";
string productionString = string.Format(
"https://management.core.windows.net/{0}/services/hostedservices/{1}/deploymentslots/{2}",
subscriptionID, hostedServiceName, "Production");
Uri requestUri = new Uri(productionString);
// Add client certificate.
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.OpenExistingOnly);
X509Certificate2Collection collection = store.Certificates.Find(
X509FindType.FindByThumbprint, thrumbnail, false);
store.Close();
if (collection.Count != 0)
{
X509Certificate2 certificate = collection[0];
HttpWebRequest httpRequest = (HttpWebRequest)HttpWebRequest.Create(requestUri);
httpRequest.ClientCertificates.Add(certificate);
httpRequest.Headers.Add("x-ms-version", "2011-10-01");
httpRequest.KeepAlive = false;
HttpWebResponse httpResponse = httpRequest.GetResponse() as HttpWebResponse;
// Get response stream from Management API.
Stream stream = httpResponse.GetResponseStream();
string result = string.Empty;
using (StreamReader reader = new StreamReader(stream))
{
result = reader.ReadToEnd();
}
if (result == null || result.Trim() == string.Empty)
{
return;
}
XDocument document = XDocument.Parse(result);
string serverID = string.Empty;
var list = from item
in document.Descendants(XName.Get("PrivateID",
"http://schemas.microsoft.com/windowsazure"))
select item;
serverID = list.First().Value;
Response.Write("Check Production: ");
Response.Write("DeploymentID : " + deploymentId
+ " ServerID :" + serverID);
if (deploymentId.Equals(serverID))
lbStatus.Text = "Production";
else
{
// If the application not in Production slot, try to check Staging slot.
string stagingString = string.Format(
"https://management.core.windows.net/{0}/services/hostedservices/{1}/deploymentslots/{2}",
subscriptionID, hostedServiceName, "Staging");
Uri stagingUri = new Uri(stagingString);
httpRequest = (HttpWebRequest)HttpWebRequest.Create(stagingUri);
httpRequest.ClientCertificates.Add(certificate);
httpRequest.Headers.Add("x-ms-version", "2011-10-01");
httpRequest.KeepAlive = false;
httpResponse = httpRequest.GetResponse() as HttpWebResponse;
stream = httpResponse.GetResponseStream();
result = string.Empty;
using (StreamReader reader = new StreamReader(stream))
{
result = reader.ReadToEnd();
}
if (result == null || result.Trim() == string.Empty)
{
return;
}
document = XDocument.Parse(result);
serverID = string.Empty;
list = from item
in document.Descendants(XName.Get("PrivateID",
"http://schemas.microsoft.com/windowsazure"))
select item;
serverID = list.First().Value;
Response.Write(" Check Staging:");
Response.Write(" DeploymentID : " + deploymentId
+ " ServerID :" + serverID);
if (deploymentId.Equals(serverID))
{
lbStatus.Text = "Staging";
}
else
{
lbStatus.Text = "Do not find this id";
}
}
httpResponse.Close();
stream.Close();
}
}
스테이징은 주로 다운타임 없는 업그레이드 및 업그레이드 롤백 기능에 사용되는 임시 배포 슬롯입니다.
시스템을 (코드 또는 구성 중 어느 쪽이든) Azure 사양과 결합하지 않는 것이 좋습니다.
Windows Azure Management Libraries와 @GuaravMantri 덕분에 다음과 같이 응답할 수 있습니다.
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Azure;
using Microsoft.WindowsAzure.Management.Compute;
using Microsoft.WindowsAzure.Management.Compute.Models;
namespace Configuration
{
public class DeploymentSlotTypeHelper
{
static string subscriptionId = "<subscription-id>";
static string managementCertContents = "<Base64 Encoded Management Certificate String from Publish Setting File>";// copy-paste it
static string cloudServiceName = "<your cloud service name>"; // lowercase
static string ns = "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration";
public DeploymentSlot GetSlotType()
{
var managementCertificate = new X509Certificate2(Convert.FromBase64String(managementCertContents));
var credentials = new CertificateCloudCredentials(subscriptionId, managementCertificate);
var computeManagementClient = new ComputeManagementClient(credentials);
var response = computeManagementClient.HostedServices.GetDetailed(cloudServiceName);
return response.Deployments.FirstOrDefault(d => d.DeploymentSlot == DeploymentSlot.Production) == null ? DeploymentSlot.Staging : DeploymentSlot.Production;
}
}
}
이 문제를 쉽게 해결할 수 있는 방법은 인스턴스에서 실행 중인 환경을 식별하는 키를 설정하는 것입니다.
1) 생산 슬롯에서 설정:[ Settings ]> [ Application settings ]> [ App settings ]를 설정하고 SLOT _ NAME 이라는 이름의 키와 "production" 값을 만듭니다.중요: 슬롯 설정을 확인합니다.
2) 스테이징 슬롯에서 설정합니다.[ Settings ]> [ Application settings ]> [ App settings ]으로 설정하고 SLOT_NAME 이라는 이름의 키와 "staging" 값을 만듭니다.중요: 슬롯 설정을 확인합니다.
응용 프로그램에서 변수에 액세스하여 응용 프로그램이 실행 중인 환경을 식별합니다.Java에서는 다음 항목에 액세스할 수 있습니다.
String slotName = System.getenv("APPSETTING_SLOT_NAME");
고려해야 할 4가지 포인트는 다음과 같습니다.
- VIP 스왑은 서비스가 외부와 마주하고 있을 때만 유효합니다.AKA: API를 공개하고 요청에 응답하는 경우.
- 큐에서 메시지를 꺼내고 처리하는 서비스만 있으면 서비스는 프로 액티브하고 VIP 스왑은 적합하지 않습니다.
- 고객의 서비스가 사후 대응적이고 능동적인 경우 설계를 재검토하는 것이 좋습니다.서비스를 2개의 다른 서비스로 분할할 수 있습니다.
- Eric이 제안하는 cscfg 파일의 VIP 스왑 전후의 변경은 서비스의 프로 액티브한 부분에 단시간 다운타임이 발생할 수 있는 경우에 적합합니다(먼저 스테이징과 실가동 양쪽에서 메시지를 풀하지 않도록 설정하고 VIP 스와프를 실행한 후 프로덕션 구성을 업데이트하여 메시지 풀링을 시작하기 때문입니다).
언급URL : https://stackoverflow.com/questions/4328462/staging-or-production-instance
'programing' 카테고리의 다른 글
파일을 재귀적으로 삭제하다 (0) | 2023.04.22 |
---|---|
내 아이폰 앱은 어떻게 자체 버전 번호를 감지합니까? (0) | 2023.04.22 |
git에서 여러 원격 분기 삭제 (0) | 2023.04.22 |
Python Setup 비활성화 경로 길이 제한 장단점? (0) | 2023.04.22 |
종속성 속성에서 세터가 실행되지 않습니까? (0) | 2023.04.17 |